結果

問題 No.2283 Prohibit Three Consecutive
ユーザー yabityabit
提出日時 2023-07-07 13:15:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 790 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 90,664 KB
最終ジャッジ日時 2023-09-28 13:43:24
合計ジャッジ時間 3,921 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,368 KB
testcase_01 AC 77 ms
71,204 KB
testcase_02 AC 76 ms
71,308 KB
testcase_03 AC 121 ms
81,312 KB
testcase_04 AC 137 ms
82,872 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 89 ms
78,436 KB
testcase_09 AC 90 ms
78,484 KB
testcase_10 AC 116 ms
90,664 KB
testcase_11 AC 120 ms
90,632 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for t in range(T):
    N = int(input())
    S = list(input())
    dp = [[0,0] for _ in range(N)]
    for i in range(2):
        if S[i] != '0':
            dp[i][1] = 1
        if S[i] != '1':
            dp[i][0] = 1
    for i in range(2, N+2):
        p,q,r = (i-2)%N, (i-1)%N, i%N
        if S[r] != '0':
            if dp[p][0] == dp[q][0] == 1 or dp[p][0] == dp[q][1] == 1 or dp[p][1] == dp[q][0] == 1:
                dp[r][1] = 1
            else:
                dp[r][1] = 0
        if S[r] != '1':
            if dp[p][0] == dp[q][1] == 1 or dp[p][1] == dp[q][0] == 1 or dp[p][1] == dp[q][1] == 1:
                dp[r][0] = 1
            else:
                dp[r][0] = 0
    if dp[1][0] == 1 or dp[1][1] == 1:
        print('Yes')
    else:
        print('No')
0