Submission #4624772
Source Code Expand
import sys input = sys.stdin.readline inf = float('inf') B = [list(map(int,input().split())) for _ in range(2)] C = [list(map(int,input().split())) for _ in range(3)] grid = [[-1]*3 for _ in range(3)] note = {} def sum2(table): res = 0 for line in table: for p in line: res += p return res def cal(table): score = 0 for i in range(2): for j in range(3): if table[i+1][j] == table[i][j]: score += B[i][j] else: score -= B[i][j] for i in range(3): for j in range(2): if table[i][j+1] == table[i][j]: score += C[i][j] else: score -= C[i][j] return score def rec(turn=0): if turn == 9: return cal(grid) if str(grid) in note: return note[str(grid)] option = inf if turn%2 else -inf for i,line in enumerate(grid): for j,p in enumerate(line): if p != -1: continue grid[i][j] = turn%2 res = rec(turn+1) if turn%2: if res < option: option = res else: if res > option: option = res grid[i][j] = -1 note[str(grid)] = option return option sum_score = sum2(B) + sum2(C) dif_score = rec() X = (sum_score + dif_score) // 2 Y = (sum_score - dif_score) // 2 print(X) print(Y)
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | pynomi |
Language | Python (3.4.3) |
Score | 100 |
Code Size | 1510 Byte |
Status | AC |
Exec Time | 123 ms |
Memory | 4280 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 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 | 109 ms | 4184 KB |
sample-02.txt | AC | 111 ms | 4216 KB |
test-01.txt | AC | 123 ms | 4208 KB |
test-02.txt | AC | 108 ms | 4192 KB |
test-03.txt | AC | 110 ms | 4184 KB |
test-04.txt | AC | 111 ms | 4216 KB |
test-05.txt | AC | 108 ms | 4224 KB |
test-06.txt | AC | 111 ms | 4216 KB |
test-07.txt | AC | 111 ms | 4224 KB |
test-08.txt | AC | 111 ms | 4192 KB |
test-09.txt | AC | 108 ms | 4220 KB |
test-10.txt | AC | 110 ms | 4216 KB |
test-11.txt | AC | 109 ms | 4240 KB |
test-12.txt | AC | 112 ms | 4216 KB |
test-13.txt | AC | 112 ms | 4184 KB |
test-14.txt | AC | 108 ms | 4188 KB |
test-15.txt | AC | 109 ms | 4224 KB |
test-16.txt | AC | 109 ms | 4276 KB |
test-17.txt | AC | 113 ms | 4220 KB |
test-18.txt | AC | 109 ms | 4220 KB |
test-19.txt | AC | 108 ms | 4280 KB |
test-20.txt | AC | 111 ms | 4216 KB |