結果

問題 No.2518 Adjacent Larger
コンテスト
ユーザー FromBooska
提出日時 2023-10-27 22:04:30
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 908 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 113 ms
コンパイル使用メモリ 85,692 KB
実行使用メモリ 101,888 KB
最終ジャッジ日時 2026-04-12 18:44:16
合計ジャッジ時間 3,180 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 実験してみると
# 和が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