結果

問題 No.2518 Adjacent Larger
ユーザー FromBooskaFromBooska
提出日時 2023-10-27 22:04:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 908 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 101,336 KB
最終ジャッジ日時 2023-10-27 22:04:40
合計ジャッジ時間 3,764 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,592 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 92 ms
76,420 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 74 ms
100,608 KB
testcase_17 AC 56 ms
83,040 KB
testcase_18 AC 56 ms
83,060 KB
testcase_19 AC 63 ms
81,092 KB
testcase_20 AC 62 ms
89,552 KB
testcase_21 AC 77 ms
101,336 KB
testcase_22 AC 76 ms
101,100 KB
testcase_23 AC 72 ms
100,656 KB
testcase_24 AC 66 ms
98,460 KB
testcase_25 AC 67 ms
98,592 KB
testcase_26 AC 67 ms
98,592 KB
testcase_27 AC 73 ms
100,692 KB
testcase_28 AC 70 ms
98,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 実験してみると
# 和がNであり、0が常に1つ以上あり、マックスが2である必要ある
# さらに2は連続できない、0も連続できない

T = int(input())
for t in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    zero_test = False
    max_test = True
    sum_test = False
    if sum(A)==N:
        sum_test = True
    for a in A:
        if a == 0:
            zero_test = True
        if a > 2:
            max_test = False

    zero_consec_test = True
    two_consec_test = True
    for i in range(N):
        if A[(i-1)%N]==2 and A[i]==2:
            two_consec_test = False
        if A[(i-1)%N]==0 and A[i]==0:
            zero_consec_test = False        

    ans = 'No'
    if sum_test == True and zero_test == True and max_test == True:
        if zero_consec_test == True and two_consec_test == True:
            ans = 'Yes'
    print(ans)
0