結果

問題 No.2283 Prohibit Three Consecutive
ユーザー ニックネームニックネーム
提出日時 2023-04-28 21:49:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 31,456 KB
最終ジャッジ日時 2024-04-28 23:27:50
合計ジャッジ時間 8,044 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 567 ms
31,316 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n = int(input()); s = input(); ans = "No"
    for i in range(4):
        dp = [[False]*4 for _ in range(n)]; dp[1][i] = True
        for j in range(2,n):
            if s[j]!="1" and dp[j-1][2]: dp[j][0] = True
            if s[j]!="0" and dp[-1][0]+dp[-1][2]: dp[j][1] = True
            if s[j]!="1" and dp[-1][1]+dp[-1][3]: dp[j][2] = True
            if s[j]!="0" and dp[j-1][1]: dp[j][3] = True
        if i==0 and dp[-1][1]+dp[-1][3]: ans = "Yes"
        if i==1 and sum(dp[-1][1:]): ans = "Yes"
        if i==2 and sum(dp[-1][:3]): ans = "Yes"
        if i==3 and dp[-1][0]+dp[-1][2]: ans = "Yes"
    print(ans)
0