結果

問題 No.2283 Prohibit Three Consecutive
ユーザー ikomaikoma
提出日時 2023-04-28 23:36:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 78,896 KB
最終ジャッジ日時 2024-04-29 00:42:28
合計ジャッジ時間 2,285 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
52,480 KB
testcase_01 AC 49 ms
52,224 KB
testcase_02 AC 42 ms
52,864 KB
testcase_03 AC 98 ms
76,032 KB
testcase_04 AC 119 ms
76,236 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 69 ms
75,776 KB
testcase_09 AC 76 ms
76,032 KB
testcase_10 AC 82 ms
76,148 KB
testcase_11 AC 81 ms
76,084 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
def judge(N,S):
    dp = [1]*8
    def sub(dp, S):
        for s in S:
            dp2 = [0]*8
            if s=="?":
                for i in range(4):
                    dp2[i  ] = dp[i<<1]|dp[(i<<1)+1] if i!=0 else 0
                    dp2[i+4] = dp[i<<1]|dp[(i<<1)+1] if i!=3 else 0
            elif s=="0":
                for i in range(4):
                    dp2[i  ] = dp[i<<1]|dp[(i<<1)+1] if i!=0 else 0
            else:
                for i in range(4):
                    dp2[i+4] = dp[i<<1]|dp[(i<<1)+1] if i!=3 else 0
            dp = dp2
        return dp
    dp = sub(dp, S)
    dp = sub(dp, S)
    return sum(dp)>0


for _ in range(T):
    N=int(input())
    S=input().strip()
    print("Yes" if judge(N,S) else "No")
0