結果
| 問題 | 
                            No.946 箱箱箱
                             | 
                    
| コンテスト | |
| ユーザー | 
                             mkawa2
                         | 
                    
| 提出日時 | 2019-12-13 21:47:48 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,395 ms / 2,000 ms | 
| コード長 | 801 bytes | 
| コンパイル時間 | 157 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 11,264 KB | 
| 最終ジャッジ日時 | 2024-06-27 15:39:12 | 
| 合計ジャッジ時間 | 29,649 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 51 | 
ソースコード
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(i,n):
            s^=aa[j]
            heappush(hp,grundy[j+1]^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()
            
            
            
        
            
mkawa2