結果

問題 No.2283 Prohibit Three Consecutive
ユーザー FromBooska
提出日時 2023-04-29 12:39:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,968 KB
実行使用メモリ 77,524 KB
最終ジャッジ日時 2024-11-18 09:48:55
合計ジャッジ時間 1,833 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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