結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,584 KB
testcase_01 AC 43 ms
51,712 KB
testcase_02 AC 42 ms
51,968 KB
testcase_03 AC 45 ms
53,120 KB
testcase_04 AC 45 ms
53,504 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 43 ms
52,608 KB
testcase_09 AC 44 ms
52,736 KB
testcase_10 AC 44 ms
52,480 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[: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