結果
問題 | No.2614 Delete ABC |
ユーザー |
|
提出日時 | 2024-01-26 21:58:13 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 729 bytes |
コンパイル時間 | 1,075 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 87,308 KB |
最終ジャッジ日時 | 2024-09-28 08:08:00 |
合計ジャッジ時間 | 4,084 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | TLE * 1 -- * 1 |
ソースコード
#条件をすべて満たすかチェックdef generate_string(N, S):if len(S) == 3 * N:if check_conditions(S):return Selse:for c in 'ABC':result = generate_string(N, S + c)if result is not None:return resultreturn Nonedef check_conditions(S):if 'AA' in S or 'BB' in S or 'CC' in S:return Falseif sorted(S) != sorted('ABC' * (len(S) // 3)):return Falsewhile 'ABC' in S:S = S.replace('ABC', '', 1)if S != '':return Truereturn FalseT = int(input())for _ in range(T):N = int(input())result = generate_string(N, '')if result is not None:print(result)