結果

問題 No.2283 Prohibit Three Consecutive
ユーザー 森中康介
提出日時 2023-04-28 22:40:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-11-17 21:37:58
合計ジャッジ時間 2,065 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for i in range(T):
    N = int(input())
    S = input()
    count0 = 0
    count1 = 0
    result = 'Yes'
    for l in range(N+2):
        if l >= N :
            l -= N
        ls = S[l]
        if ls == '0':
            count0 += 1
            count1 = 0
        elif ls == '1':
            count1 += 1
            count0 = 0
        else:
            if count1 == 2:
                count0 += 1
                count1 = 0
            elif count0 == 2:
                count1 += 1
                count0 = 0
            else:
                laf = l+1
                if laf >= N:
                    laf = l +1 - N
                if S[laf] == '1':
                    count0 += 1
                    count1 = 0
                elif S[laf] == '0':
                    count1 += 1
                    count0 = 0

            
        if count0 == 3 or count1 == 3:
            result = 'No'
    print(result)
0