結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,096 KB
testcase_01 AC 43 ms
51,712 KB
testcase_02 WA -
testcase_03 AC 90 ms
75,264 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 52 ms
58,752 KB
testcase_09 AC 55 ms
65,152 KB
testcase_10 AC 59 ms
66,432 KB
testcase_11 AC 58 ms
66,432 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

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