Submission #1792122
Source Code Expand
#include <stdio.h> #include <stdlib.h> typedef struct { int a; int b; }pair; int **b, **c; char **a; pair solve(int rest){ int i, j; pair ans, p; ans.a = 0; ans.b = 0; if(rest == 0){ for(i = 0; i < 2; i++){ for(j = 0; j < 3; j++){ if(a[i][j] == a[i + 1][j]){ ans.a += b[i][j]; } else{ ans.b += b[i][j]; } } } for(i = 0; i < 3; i++){ for(j = 0; j < 2; j++){ if(a[i][j] == a[i][j + 1]){ ans.a += c[i][j]; } else{ ans.b += c[i][j]; } } } } else if(rest % 2 == 1){ for(i = 0; i < 3; i++){ for(j = 0; j < 3; j++){ if(a[i][j] == '.'){ a[i][j] = 'o'; p = solve(rest - 1); if(p.a > ans.a){ ans = p; } a[i][j] = '.'; } } } } else{ for(i = 0; i < 3; i++){ for(j = 0; j < 3; j++){ if(a[i][j] == '.'){ a[i][j] = 'x'; p = solve(rest - 1); if(p.b > ans.b){ ans = p; } a[i][j] = '.'; } } } } return ans; } int main(){ int i, j; b = (int **)malloc(sizeof(int *) * 2); for(i = 0; i < 2; i++){ b[i] = (int *)malloc(sizeof(int) * 3); for(j = 0; j < 3; j++){ scanf("%d", &b[i][j]); } } c = (int **)malloc(sizeof(int *) * 3); for(i = 0; i < 3; i++){ c[i] = (int *)malloc(sizeof(int) * 2); for(j = 0; j < 2; j++){ scanf("%d", &c[i][j]); } } a = (char **)malloc(sizeof(char *) * 3); for(i = 0; i < 3; i++){ a[i] = (char *)malloc(sizeof(char) * 3); for(j = 0; j < 3; j++){ a[i][j] = '.'; } } pair ans = solve(9); printf("%d\n%d\n", ans.a, ans.b); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | abc050 |
Language | C (GCC 5.4.1) |
Score | 0 |
Code Size | 1656 Byte |
Status | WA |
Exec Time | 33 ms |
Memory | 128 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:76:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &b[i][j]); ^ ./Main.c:83:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &c[i][j]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt |
All | sample-01.txt, sample-02.txt, test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample-01.txt | AC | 33 ms | 128 KB |
sample-02.txt | AC | 33 ms | 128 KB |
test-01.txt | AC | 33 ms | 128 KB |
test-02.txt | AC | 33 ms | 128 KB |
test-03.txt | AC | 33 ms | 128 KB |
test-04.txt | WA | 33 ms | 128 KB |
test-05.txt | WA | 33 ms | 128 KB |
test-06.txt | WA | 33 ms | 128 KB |
test-07.txt | AC | 33 ms | 128 KB |
test-08.txt | AC | 33 ms | 128 KB |
test-09.txt | AC | 33 ms | 128 KB |
test-10.txt | AC | 33 ms | 128 KB |
test-11.txt | AC | 32 ms | 128 KB |
test-12.txt | WA | 33 ms | 128 KB |
test-13.txt | WA | 33 ms | 128 KB |
test-14.txt | AC | 33 ms | 128 KB |
test-15.txt | WA | 33 ms | 128 KB |
test-16.txt | AC | 33 ms | 128 KB |
test-17.txt | WA | 33 ms | 128 KB |
test-18.txt | AC | 33 ms | 128 KB |
test-19.txt | WA | 33 ms | 128 KB |
test-20.txt | AC | 33 ms | 128 KB |