結果
| 問題 |
No.2518 Adjacent Larger
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-27 21:45:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 864 bytes |
| コンパイル時間 | 341 ms |
| コンパイル使用メモリ | 82,144 KB |
| 実行使用メモリ | 148,176 KB |
| 最終ジャッジ日時 | 2024-09-25 13:51:13 |
| 合計ジャッジ時間 | 4,404 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 WA * 10 |
ソースコード
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
def sol():
n = int(input())
a = list(map(int,input().split()))
a = a+a
ok = 1
for i in range(2):
lr = [[]]
for i in range(2*n):
if a[i] == 0:
lr.append([])
else:
lr[-1].append(a[i])
if len(lr) == 1:
ok = 0
for i in range(len(lr)):
if lr[i].count(2) >= 2:
ok = 0
for i in range(2*n):
if a[i] == 0:
a[i] = 2
if a[i] == 2:
a[i] = 0
print('Yes') if ok else print('No')
return
T = int(input())
for i in range(T):
sol()