結果
問題 | No.2518 Adjacent Larger |
ユーザー |
![]() |
提出日時 | 2023-12-21 23:32:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 667 bytes |
コンパイル時間 | 404 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 100,516 KB |
最終ジャッジ日時 | 2024-09-27 11:10:35 |
合計ジャッジ時間 | 3,463 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 WA * 15 |
ソースコード
for _ in range(int(input())): N = int(input()) A = list(map(int, input().split())) if sum(A) != N: print("No") exit() if 0 not in A: print("No") continue j = A.index(0) f = 0 ans = True for i in range(1, N + 1): if f == 0: if A[(i + j) % N] == 0: ans = False break if A[(i + j) % N] == 2: f = 2 elif f == 2: if A[(i + j) % N] == 2: ans = False break if A[(i + j) % N] == 0: f = 0 if ans: print("Yes") else: print("No")