結果

問題 No.2283 Prohibit Three Consecutive
ユーザー 森中康介森中康介
提出日時 2023-04-28 22:42:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,550 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 77,376 KB
最終ジャッジ日時 2024-04-29 00:07:39
合計ジャッジ時間 2,150 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,584 KB
testcase_01 AC 39 ms
52,224 KB
testcase_02 WA -
testcase_03 AC 85 ms
75,904 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 51 ms
59,520 KB
testcase_09 AC 51 ms
66,176 KB
testcase_10 AC 49 ms
66,432 KB
testcase_11 AC 49 ms
66,176 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

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
                else:
                    lafaf = laf+1
                    if lafaf >= N:
                        lafaf = laf + 1 - N
                    if S[lafaf] == '1':
                        count0 += 1
                        count1 = 0
                    elif S[lafaf] == '0':
                        count1 += 1
                        count0 = 0
                    else:
                        if count1 > 0:
                            count0 += 1
                            count1 = 0
                        elif count0 > 0:
                            count1 += 1
                            count0 = 0
            
        if count0 == 3 or count1 == 3:
            result = 'No'
    print(result)
0