結果

問題 No.2518 Adjacent Larger
ユーザー hato336hato336
提出日時 2023-10-28 09:11:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 116,624 KB
最終ジャッジ日時 2023-10-28 09:11:52
合計ジャッジ時間 7,860 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 215 ms
90,216 KB
testcase_08 AC 240 ms
89,672 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 198 ms
116,588 KB
testcase_17 AC 185 ms
103,048 KB
testcase_18 AC 184 ms
103,068 KB
testcase_19 AC 180 ms
101,028 KB
testcase_20 AC 217 ms
107,660 KB
testcase_21 AC 181 ms
116,340 KB
testcase_22 AC 190 ms
116,344 KB
testcase_23 AC 192 ms
116,624 KB
testcase_24 AC 189 ms
116,512 KB
testcase_25 AC 185 ms
116,596 KB
testcase_26 AC 185 ms
116,592 KB
testcase_27 AC 217 ms
116,604 KB
testcase_28 AC 185 ms
116,596 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
    c = 0
    for i in range(n):
        if alist[i] == 2:
            if alist[i-1] == 2 or alist[(i+1)%n] == 2:
                print('No')
                c = 1
                break
        if alist[i] == 1:
            if alist[i-1] == 2 and alist[(i+1)%n] == 2:
                print('No')
                c = 1
                break
    if alist.count(2) == 0:
        print('No')
        c = 1
    if alist.count(0) == 0:
        print('No')
        c = 1
    if not c:
        print('Yes')
0