結果

問題 No.946 箱箱箱
コンテスト
ユーザー maspy
提出日時 2020-03-31 16:38:51
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 763 ms / 2,000 ms
コード長 486 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 444 ms
コンパイル使用メモリ 20,852 KB
実行使用メモリ 41,636 KB
最終ジャッジ日時 2026-03-11 00:28:56
合計ジャッジ時間 39,506 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
N, *A = map(int, read().split())

dp = np.zeros(N + 1, np.int32)
for i, x in enumerate(A[::-1]):
    dp[:i + 1] ^= x
    values = np.unique(dp[: i + 1])
    n = len(values)
    ind = np.where(np.arange(n) != values)[0]
    dp[i + 1] = n if not len(ind) else ind[0]

answer = 'Takahashi' if dp[-1] else 'Takanashi'
print(answer)
0