提出 #24142088
ソースコード 拡げる
S=[s[:-1]for s in open(0)][1:]
N=len(S)
from collections import defaultdict
from collections import deque
d=defaultdict(list)#keyにいけるやつ
f=defaultdict(list)#keyからいけるやつ
for i,s in enumerate(S):
d[s[-3:]].append(i)
for i,s in enumerate(S):
f[s[:3]].append(i)
q=deque()
deg=[len(f[s[-3:]])for s in S]
YET=-1
visited=1
V=[YET]*N
dp=[-1]*N
for i in range(N):
if deg[i]==0:
dp[i]=0
q.append(i)
while q:
v=q.popleft()
for nv in d[S[v][:3]]:
if V[nv]==visited:
continue
deg[nv]-=1
if dp[v]==0:
dp[nv]=1
q.append(nv)
V[nv]=visited
elif dp[v]==1:
if deg[nv]==0:
dp[nv]=0
q.append(nv)
V[nv]=visited
for i in dp:
print(('Takahashi','Aoki','Draw')[i])
提出情報
| 提出日時 | |
|---|---|
| 問題 | E - Shiritori |
| ユーザ | Pandruant |
| 言語 | PyPy3 (7.3.0) |
| 得点 | 500 |
| コード長 | 753 Byte |
| 結果 | AC |
| 実行時間 | 561 ms |
| メモリ | 164080 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 500 / 500 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_00.txt, sample_01.txt, sample_02.txt |
| All | case_00.txt, case_01.txt, case_02.txt, case_03.txt, case_04.txt, case_05.txt, case_06.txt, case_07.txt, case_08.txt, case_09.txt, case_10.txt, case_11.txt, case_12.txt, case_13.txt, case_14.txt, case_15.txt, case_16.txt, case_17.txt, case_18.txt, case_19.txt, case_20.txt, case_21.txt, case_22.txt, case_23.txt, case_24.txt, case_25.txt, case_26.txt, case_27.txt, case_28.txt, case_29.txt, case_30.txt, case_31.txt, case_32.txt, case_33.txt, case_34.txt, case_35.txt, case_36.txt, case_37.txt, case_38.txt, case_39.txt, case_40.txt, case_41.txt, case_42.txt, case_43.txt, case_44.txt, case_45.txt, case_46.txt, case_47.txt, case_48.txt, case_49.txt, case_50.txt, case_51.txt, case_52.txt, case_53.txt, case_54.txt, case_55.txt, case_56.txt, case_57.txt, case_58.txt, case_59.txt, sample_00.txt, sample_01.txt, sample_02.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| case_00.txt | AC | 448 ms | 147996 KiB |
| case_01.txt | AC | 419 ms | 147904 KiB |
| case_02.txt | AC | 421 ms | 147964 KiB |
| case_03.txt | AC | 422 ms | 147720 KiB |
| case_04.txt | AC | 421 ms | 147904 KiB |
| case_05.txt | AC | 430 ms | 154180 KiB |
| case_06.txt | AC | 430 ms | 154044 KiB |
| case_07.txt | AC | 432 ms | 154308 KiB |
| case_08.txt | AC | 409 ms | 154320 KiB |
| case_09.txt | AC | 408 ms | 154276 KiB |
| case_10.txt | AC | 534 ms | 154360 KiB |
| case_11.txt | AC | 519 ms | 151012 KiB |
| case_12.txt | AC | 518 ms | 154212 KiB |
| case_13.txt | AC | 518 ms | 154340 KiB |
| case_14.txt | AC | 523 ms | 150968 KiB |
| case_15.txt | AC | 60 ms | 64904 KiB |
| case_16.txt | AC | 59 ms | 64868 KiB |
| case_17.txt | AC | 59 ms | 65168 KiB |
| case_18.txt | AC | 60 ms | 65140 KiB |
| case_19.txt | AC | 59 ms | 65008 KiB |
| case_20.txt | AC | 58 ms | 65232 KiB |
| case_21.txt | AC | 56 ms | 65180 KiB |
| case_22.txt | AC | 57 ms | 65156 KiB |
| case_23.txt | AC | 297 ms | 147688 KiB |
| case_24.txt | AC | 294 ms | 147752 KiB |
| case_25.txt | AC | 295 ms | 147584 KiB |
| case_26.txt | AC | 397 ms | 147904 KiB |
| case_27.txt | AC | 400 ms | 147876 KiB |
| case_28.txt | AC | 400 ms | 147992 KiB |
| case_29.txt | AC | 387 ms | 163984 KiB |
| case_30.txt | AC | 382 ms | 164080 KiB |
| case_31.txt | AC | 388 ms | 164000 KiB |
| case_32.txt | AC | 404 ms | 138788 KiB |
| case_33.txt | AC | 561 ms | 152776 KiB |
| case_34.txt | AC | 521 ms | 149596 KiB |
| case_35.txt | AC | 224 ms | 104140 KiB |
| case_36.txt | AC | 288 ms | 118336 KiB |
| case_37.txt | AC | 470 ms | 145388 KiB |
| case_38.txt | AC | 468 ms | 143804 KiB |
| case_39.txt | AC | 351 ms | 131784 KiB |
| case_40.txt | AC | 366 ms | 130884 KiB |
| case_41.txt | AC | 224 ms | 104008 KiB |
| case_42.txt | AC | 376 ms | 131364 KiB |
| case_43.txt | AC | 242 ms | 108944 KiB |
| case_44.txt | AC | 288 ms | 116480 KiB |
| case_45.txt | AC | 189 ms | 97216 KiB |
| case_46.txt | AC | 496 ms | 146880 KiB |
| case_47.txt | AC | 199 ms | 99116 KiB |
| case_48.txt | AC | 366 ms | 136348 KiB |
| case_49.txt | AC | 270 ms | 116396 KiB |
| case_50.txt | AC | 407 ms | 146708 KiB |
| case_51.txt | AC | 376 ms | 145452 KiB |
| case_52.txt | AC | 370 ms | 142380 KiB |
| case_53.txt | AC | 421 ms | 155492 KiB |
| case_54.txt | AC | 353 ms | 130608 KiB |
| case_55.txt | AC | 141 ms | 82748 KiB |
| case_56.txt | AC | 267 ms | 118932 KiB |
| case_57.txt | AC | 161 ms | 94088 KiB |
| case_58.txt | AC | 301 ms | 128908 KiB |
| case_59.txt | AC | 392 ms | 148408 KiB |
| sample_00.txt | AC | 57 ms | 65156 KiB |
| sample_01.txt | AC | 58 ms | 64968 KiB |
| sample_02.txt | AC | 60 ms | 65036 KiB |