結果
| 問題 | No.2283 Prohibit Three Consecutive |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-08-03 22:20:50 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 622 bytes |
| 記録 | |
| コンパイル時間 | 235 ms |
| コンパイル使用メモリ | 95,976 KB |
| 実行使用メモリ | 84,736 KB |
| 最終ジャッジ日時 | 2026-08-03 22:20:53 |
| 合計ジャッジ時間 | 2,387 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 WA * 5 |
ソースコード
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
N = int(input())
S = input().rstrip("\n")
cnt1, cnt2 = 0, 0
for s in S*2:
if s == "0":
cnt2 = 0
cnt1 += 1
elif s == "1":
cnt1 = 0
cnt2 += 1
else:
if cnt1 == 2:
cnt2 = 1
cnt1 = 0
elif cnt2 == 2:
cnt1 = 1
cnt2 = 0
else:
cnt1, cnt2 = 0, 0
if max(cnt1, cnt2) == 3:
print("No")
break
else:
print("Yes")
detteiuu