結果
| 問題 |
No.2518 Adjacent Larger
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2023-12-21 23:33:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 198 ms / 2,000 ms |
| コード長 | 669 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 82,276 KB |
| 実行使用メモリ | 99,784 KB |
| 最終ジャッジ日時 | 2024-09-27 11:10:39 |
| 合計ジャッジ時間 | 3,952 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
for _ in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
if sum(A) != N:
print("No")
continue
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")
ntuda