結果

問題 No.2283 Prohibit Three Consecutive
ユーザー FromBooskaFromBooska
提出日時 2023-04-29 12:39:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,696 KB
最終ジャッジ日時 2024-04-29 08:11:33
合計ジャッジ時間 1,902 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
51,712 KB
testcase_01 AC 46 ms
51,840 KB
testcase_02 AC 41 ms
51,840 KB
testcase_03 AC 46 ms
52,992 KB
testcase_04 AC 46 ms
53,248 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 44 ms
52,480 KB
testcase_09 AC 44 ms
52,480 KB
testcase_10 AC 45 ms
52,352 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 文字列Sは最初の4字を最後にもくっつけて判断
# 000 or 111があればNo
# 00?11, 11?00があればNo
# あとはYes

T = int(input())
for t in range(T):
    N = int(input())
    S = input()
    S2 = S+S
    #S2 = S + S[:min(N, 4)]
    #print(S2)
    ans = 'Yes'
    if '000' in S2 or '111' in S2:
        ans = 'No'
    if '00?11' in S2 or '11?00' in S2:
        ans = 'No'
    print(ans)
0