結果
問題 | No.2518 Adjacent Larger |
ユーザー | flygon |
提出日時 | 2023-10-27 21:48:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 166 ms / 2,000 ms |
コード長 | 867 bytes |
コンパイル時間 | 318 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 147,956 KB |
最終ジャッジ日時 | 2024-09-25 13:53:49 |
合計ジャッジ時間 | 4,847 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
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 elif a[i] == 2: a[i] = 0 print('Yes') if ok else print('No') return T = int(input()) for i in range(T): sol()