結果

問題 No.2518 Adjacent Larger
ユーザー hato336hato336
提出日時 2023-10-28 09:27:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 878 bytes
コンパイル時間 1,028 ms
コンパイル使用メモリ 81,520 KB
実行使用メモリ 118,392 KB
最終ジャッジ日時 2023-10-28 09:27:59
合計ジャッジ時間 7,349 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
84,952 KB
testcase_01 AC 271 ms
90,148 KB
testcase_02 AC 262 ms
90,168 KB
testcase_03 AC 270 ms
89,888 KB
testcase_04 AC 262 ms
90,156 KB
testcase_05 AC 263 ms
89,888 KB
testcase_06 AC 201 ms
90,408 KB
testcase_07 AC 217 ms
89,852 KB
testcase_08 AC 206 ms
89,708 KB
testcase_09 AC 210 ms
89,668 KB
testcase_10 AC 208 ms
90,288 KB
testcase_11 AC 165 ms
89,164 KB
testcase_12 AC 163 ms
89,240 KB
testcase_13 AC 167 ms
89,172 KB
testcase_14 AC 160 ms
89,212 KB
testcase_15 AC 175 ms
89,280 KB
testcase_16 AC 199 ms
118,316 KB
testcase_17 AC 168 ms
104,140 KB
testcase_18 AC 166 ms
104,184 KB
testcase_19 AC 165 ms
101,972 KB
testcase_20 AC 172 ms
108,968 KB
testcase_21 AC 164 ms
116,352 KB
testcase_22 AC 170 ms
116,352 KB
testcase_23 AC 193 ms
118,392 KB
testcase_24 AC 173 ms
118,196 KB
testcase_25 AC 172 ms
118,336 KB
testcase_26 AC 175 ms
118,360 KB
testcase_27 AC 172 ms
118,360 KB
testcase_28 AC 175 ms
118,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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