Submission #52204714
Source Code Expand
import sys
input = sys.stdin.readline
def check(colors):
return len(set(colors)) == 1 and colors[0] != -1
def rec(turn):
# check row
for i in range(3):
if check([state[3 * i + j] for j in range(3)]):
return state[3 * i]
# check col
for j in range(3):
if check([state[3 * i + j] for i in range(3)]):
return state[j]
# check diag
if check([state[3 * i + i] for i in range(3)]):
return state[0]
if check([state[3 * i + 2 - i] for i in range(3)]):
return state[2]
# all painted
if -1 not in state:
score = [0] * 2
for i in range(3):
for j in range(3):
score[state[3 * i + j]] += A[i][j]
return 0 if score[0] > score[1] else 1
for k in range(9):
if state[k] == -1:
state[k] = turn
if rec(turn ^ 1) == turn:
state[k] = -1
return turn
state[k] = -1
return turn ^ 1
A = [list(map(int, input().split())) for _ in range(3)]
state = [-1] * 9
print(["Takahashi", "Aoki"][rec(0)])
Submission Info
| Submission Time | |
|---|---|
| Task | E - Weighted Tic-Tac-Toe |
| User | sotanishy |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 450 |
| Code Size | 1152 Byte |
| Status | AC |
| Exec Time | 130 ms |
| Memory | 84344 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 450 / 450 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt, 02_handmade_09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 103 ms | 83532 KiB |
| 00_sample_02.txt | AC | 117 ms | 83628 KiB |
| 01_random_01.txt | AC | 114 ms | 84008 KiB |
| 01_random_02.txt | AC | 84 ms | 83184 KiB |
| 01_random_03.txt | AC | 119 ms | 83780 KiB |
| 01_random_04.txt | AC | 100 ms | 83392 KiB |
| 01_random_05.txt | AC | 120 ms | 83384 KiB |
| 01_random_06.txt | AC | 85 ms | 83168 KiB |
| 01_random_07.txt | AC | 124 ms | 83600 KiB |
| 01_random_08.txt | AC | 87 ms | 83204 KiB |
| 01_random_09.txt | AC | 120 ms | 83696 KiB |
| 01_random_10.txt | AC | 90 ms | 83196 KiB |
| 01_random_11.txt | AC | 119 ms | 83364 KiB |
| 01_random_12.txt | AC | 89 ms | 83224 KiB |
| 01_random_13.txt | AC | 119 ms | 83400 KiB |
| 01_random_14.txt | AC | 90 ms | 83380 KiB |
| 01_random_15.txt | AC | 122 ms | 84088 KiB |
| 01_random_16.txt | AC | 87 ms | 83792 KiB |
| 01_random_17.txt | AC | 115 ms | 83708 KiB |
| 01_random_18.txt | AC | 92 ms | 83048 KiB |
| 01_random_19.txt | AC | 120 ms | 83712 KiB |
| 01_random_20.txt | AC | 91 ms | 83432 KiB |
| 02_handmade_01.txt | AC | 123 ms | 83560 KiB |
| 02_handmade_02.txt | AC | 104 ms | 83620 KiB |
| 02_handmade_03.txt | AC | 123 ms | 83380 KiB |
| 02_handmade_04.txt | AC | 83 ms | 82888 KiB |
| 02_handmade_05.txt | AC | 117 ms | 83856 KiB |
| 02_handmade_06.txt | AC | 111 ms | 83668 KiB |
| 02_handmade_07.txt | AC | 120 ms | 84344 KiB |
| 02_handmade_08.txt | AC | 130 ms | 84104 KiB |
| 02_handmade_09.txt | AC | 83 ms | 83092 KiB |