結果
問題 |
No.946 箱箱箱
|
ユーザー |
![]() |
提出日時 | 2019-12-13 21:34:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 806 bytes |
コンパイル時間 | 90 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-06-27 15:32:38 |
合計ジャッジ時間 | 20,969 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 19 |
ソースコード
from heapq import * from collections import defaultdict import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): n=int(input()) aa=[int(input()) for _ in range(n)] grundy=[0]*(n+1) for i in range(n-1,-1,-1): hp=[] s=0 for j in range(n-1,i-1,-1): s^=aa[j] heappush(hp,grundy[j]^s) g=-1 while hp: ng=heappop(hp) if ng!=g+1:break g=ng grundy[i]=g+1 if grundy[0]:print("Takahashi") else:print("Takanashi") #print(grundy) main()