結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
tnodino
|
| 提出日時 | 2022-07-22 19:52:45 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 572 bytes |
| コンパイル時間 | 95 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-04 03:49:12 |
| 合計ジャッジ時間 | 2,476 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 WA * 19 |
ソースコード
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())
T = input()
if not T in memo:
print('SUCCESS')
elif S == T and len(set(S)) == 1:
print('FAILURE')
elif memo[T] <= N and memo[T] % 2 == N % 2:
print('FAILURE')
else:
print('SUCCESS')
tnodino