結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
tnodino
|
| 提出日時 | 2022-07-22 19:50:00 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 517 bytes |
| コンパイル時間 | 121 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-04 03:46:14 |
| 合計ジャッジ時間 | 2,864 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 WA * 23 |
ソースコード
from collections import deque
S = input()
memo = {}
memo[S] = 0
Queue = deque()
Queue.append((S, 0))
while Queue:
x,cnt = Queue.popleft()
y = x[1] + x[0] + x[2]
if not y in memo:
memo[y] = cnt + 1
Queue.append((y, cnt+1))
y = x[0] + x[2] + x[1]
if not y in memo:
memo[y] = cnt + 1
Queue.append((y, cnt+1))
N = int(input())
S = input()
if not S in memo:
print('SUCCESS')
elif memo[S] <= N and memo[S] % 2 == N % 2:
print('FAILURE')
else:
print('SUCCESS')
tnodino