Submission #3518748
Source Code Expand
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x)-1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) a = [[-1 for _ in range(3)] for _ in range(3)] b = [list(li()) for _ in range(2)] c = [list(li()) for _ in range(3)] def minimax(cnt: int): if cnt == 9: result = 0 # 縦方向の一致 for i in range(2): for j in range(3): if a[i][j] == a[i+1][j]: result += b[i][j] # 横方向の一致 for i in range(3): for j in range(2): if a[i][j] == a[i][j+1]: result += c[i][j] return result else: # 0: 直大, 1: 直子 turn = cnt%2 ret = (-1)**(cnt+1) * (10**18) for i in range(3): for j in range(3): if a[i][j] == -1: a[i][j] = turn if turn: ret = min(ret, minimax(cnt+1)) else: ret = max(ret, minimax(cnt+1)) a[i][j] = -1 return ret ans = minimax(0) print(ans) print(sum([sum(b[i]) for i in range(2)]) + sum([sum(c[i]) for i in range(3)]) - ans)
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | polarbear08 |
Language | PyPy3 (2.4.0) |
Score | 100 |
Code Size | 1725 Byte |
Status | AC |
Exec Time | 777 ms |
Memory | 66268 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 | 777 ms | 64476 KB |
sample-02.txt | AC | 766 ms | 63580 KB |
test-01.txt | AC | 725 ms | 60892 KB |
test-02.txt | AC | 771 ms | 62684 KB |
test-03.txt | AC | 723 ms | 60508 KB |
test-04.txt | AC | 752 ms | 62172 KB |
test-05.txt | AC | 770 ms | 63964 KB |
test-06.txt | AC | 762 ms | 63068 KB |
test-07.txt | AC | 731 ms | 61020 KB |
test-08.txt | AC | 765 ms | 63196 KB |
test-09.txt | AC | 722 ms | 61276 KB |
test-10.txt | AC | 773 ms | 63708 KB |
test-11.txt | AC | 773 ms | 66268 KB |
test-12.txt | AC | 762 ms | 63708 KB |
test-13.txt | AC | 776 ms | 64092 KB |
test-14.txt | AC | 716 ms | 60636 KB |
test-15.txt | AC | 762 ms | 63836 KB |
test-16.txt | AC | 769 ms | 63452 KB |
test-17.txt | AC | 766 ms | 63580 KB |
test-18.txt | AC | 768 ms | 63452 KB |
test-19.txt | AC | 769 ms | 63708 KB |
test-20.txt | AC | 731 ms | 61148 KB |