結果
| 問題 | No.3374 Caesar Shift Game |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-11-22 05:29:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 995 bytes |
| 記録 | |
| コンパイル時間 | 307 ms |
| コンパイル使用メモリ | 82,576 KB |
| 実行使用メモリ | 104,140 KB |
| 最終ジャッジ日時 | 2025-11-22 05:29:10 |
| 合計ジャッジ時間 | 5,841 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 4 TLE * 1 -- * 29 |
ソースコード
import sys
sys.setrecursionlimit(10**6)
def find_abc(cs: list, used: set):
a = b = c = INF
for i, x in enumerate(cs):
if x == 'A':
if i not in used:
a = min(a, i)
elif x == 'B':
if i not in used:
b = min(b, i)
elif x == 'C':
if i not in used:
c = min(c, i)
return a, b, c
def f(cs: list, used: set):
a, b, c = find_abc(cs, used)
if c < a and c < b:
cs[c] = 'A'
used.add(c)
return g(cs, used)
return cs
def g(cs: list, used: set):
a, b, c = find_abc(cs, used)
if c < a and c < b:
return cs
if a < b:
cs[a] = 'B'
used.add(a)
elif b < INF:
cs[b] = 'C'
used.add(b)
return f(cs, used)
def solve():
N = int(input())
S = input()
res = f(list(S), set())
return ''.join(res)
INF = 1 << 60
T = int(input())
for _ in range(T):
ans = solve()
print(ans)
norioc