結果
| 問題 |
No.2518 Adjacent Larger
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-28 09:27:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 276 ms / 2,000 ms |
| コード長 | 878 bytes |
| コンパイル時間 | 390 ms |
| コンパイル使用メモリ | 82,024 KB |
| 実行使用メモリ | 119,212 KB |
| 最終ジャッジ日時 | 2024-09-25 16:13:37 |
| 合計ジャッジ時間 | 7,260 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
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
if 2 not in alist:
print('No')
continue
x = alist.index(2)
blist = [None for i in range(n)]
for i in range(n):
if alist[x] == 2:
blist[x] = '>'
if alist[x] == 1:
blist[x] = blist[x-1]
if alist[x] == 0:
blist[x] = '<'
x += 1
x %= n
c = 0
for i in range(n):
if alist[i] != (blist[i] == '>') + (blist[i-1] == '<'):
print('No')
c = 1
break
if c == 0:
print('Yes')