結果
問題 | No.2518 Adjacent Larger |
ユーザー |
|
提出日時 | 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 syssys.setrecursionlimit(5*10**5)input = sys.stdin.readlinefrom collections import defaultdict, deque, Counterfrom heapq import heappop, heappushfrom bisect import bisect_left, bisect_rightfrom math import gcddef sol():n = int(input())a = list(map(int,input().split()))a = a+aok = 1for 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 = 0for i in range(len(lr)):if lr[i].count(2) >= 2:ok = 0for i in range(2*n):if a[i] == 0:a[i] = 2elif a[i] == 2:a[i] = 0print('Yes') if ok else print('No')returnT = int(input())for i in range(T):sol()