結果
| 問題 |
No.2518 Adjacent Larger
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-28 09:16:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 994 bytes |
| コンパイル時間 | 269 ms |
| コンパイル使用メモリ | 82,388 KB |
| 実行使用メモリ | 117,504 KB |
| 最終ジャッジ日時 | 2024-09-25 16:13:11 |
| 合計ジャッジ時間 | 6,834 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 WA * 14 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#alist = []
#s = input()
t = int(input())
for _ in range(t):
n = int(input())
alist = list(map(int,input().split()))
if sum(alist) != n:
print('No')
continue
c = 0
for i in range(n):
if alist[i] == 2:
if alist[i-1] == 2 or alist[(i+1)%n] == 2:
print('No')
c = 1
break
if alist[i] == 1:
if alist[i-1] == 2 and alist[(i+1)%n] == 2:
print('No')
c = 1
break
if alist[i] == 0:
if alist[i-1] == 0 or alist[(i+1)%n] == 0:
print('No')
c = 1
break
if (alist.count(2) == 0 or alist.count(0) == 0 or alist.count(1) == 0) and c == 0:
print('No')
c = 1
if not c:
print('Yes')