結果
| 問題 | No.2518 Adjacent Larger |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-10-28 00:36:10 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 536 bytes |
| 記録 | |
| コンパイル時間 | 972 ms |
| コンパイル使用メモリ | 21,340 KB |
| 実行使用メモリ | 20,452 KB |
| 最終ジャッジ日時 | 2026-09-04 05:12:08 |
| 合計ジャッジ時間 | 8,062 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 WA * 10 |
ソースコード
import sys
def solve(n, a):
left = [False] * n
right = [False] * n
idx2 = -1
for i in range(n):
if a[i] == 2:
idx2 = i
break
if idx2 == -1:
return False
left[idx2] = True
right[idx2] = True
for i in range(idx2 + 1, idx2 + n):
j = i % n
left[j] = not right[j-1]
if a[j] == 0 and left[j] or a[j] == 2 and not left[j]:
return False
right[j] = (a[j] - left[j]) > 0
return True
t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
print("Yes" if solve(n, a) else "No")