結果

問題 No.2283 Prohibit Three Consecutive
ユーザー lloyzlloyz
提出日時 2023-04-28 22:16:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 80,128 KB
最終ジャッジ日時 2024-04-28 23:49:24
合計ジャッジ時間 2,595 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,584 KB
testcase_01 AC 43 ms
52,224 KB
testcase_02 AC 42 ms
51,968 KB
testcase_03 AC 62 ms
70,400 KB
testcase_04 AC 74 ms
75,776 KB
testcase_05 AC 254 ms
78,884 KB
testcase_06 AC 248 ms
78,844 KB
testcase_07 AC 44 ms
51,840 KB
testcase_08 AC 88 ms
80,128 KB
testcase_09 AC 99 ms
79,744 KB
testcase_10 AC 103 ms
80,128 KB
testcase_11 AC 88 ms
79,616 KB
testcase_12 AC 241 ms
79,060 KB
testcase_13 AC 269 ms
79,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n = int(input())
    S = list(input())
    flag = True
    for _ in range(2):
        for i in range(n):
            C = [0, 0]
            q_idx = []
            for j in range(3):
                if S[(i + j) % n] == '0':
                    C[0] += 1
                elif S[(i + j) % n] == '1':
                    C[1] += 1
                else:
                    q_idx.append((i + j) % n)
            if C[0] == 3 or C[1] == 3:
                flag = False
                break
            if C[0] == 2 and C[1] == 0:
                S[q_idx[0]] = '1'
            if C[1] == 2 and C[0] == 0:
                S[q_idx[0]] = '0'
        if not flag:
            break
    if flag:
        print("Yes")
    else:
        print("No")
0