結果

問題 No.2518 Adjacent Larger
ユーザー flygonflygon
提出日時 2023-10-27 21:45:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 864 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 147,796 KB
最終ジャッジ日時 2023-10-27 21:45:48
合計ジャッジ時間 4,637 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,692 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 78 ms
75,896 KB
testcase_12 AC 81 ms
75,928 KB
testcase_13 AC 82 ms
75,920 KB
testcase_14 AC 79 ms
75,888 KB
testcase_15 AC 81 ms
75,900 KB
testcase_16 AC 163 ms
122,872 KB
testcase_17 AC 112 ms
99,300 KB
testcase_18 AC 108 ms
99,372 KB
testcase_19 AC 103 ms
98,712 KB
testcase_20 AC 117 ms
102,500 KB
testcase_21 AC 166 ms
119,448 KB
testcase_22 AC 162 ms
120,820 KB
testcase_23 AC 160 ms
122,420 KB
testcase_24 AC 124 ms
147,796 KB
testcase_25 AC 113 ms
126,192 KB
testcase_26 AC 117 ms
133,316 KB
testcase_27 AC 157 ms
128,488 KB
testcase_28 AC 155 ms
128,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0