結果

問題 No.2518 Adjacent Larger
ユーザー june19312
提出日時 2023-10-27 22:02:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 635 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 82,084 KB
実行使用メモリ 110,048 KB
最終ジャッジ日時 2024-09-25 14:08:29
合計ジャッジ時間 4,032 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    N = int(input())
    A = list(map(str,input().split()))
    B = "".join(A)
    if "22" in B or "00" in B:
        print("No")
        continue
    if B.find("0") == -1 or B.find("2") == -1:
        print("No")
        continue
    if B.count("2") != B.count("0"):
        print("No")
        continue
    if B[0] == "0" and B[-1] == "0":
        print("No")
        continue
    if B[0] == "2" and B[-1] == "2":
        print("No")
        continue

    cnt = 0
    for ii,vv in enumerate(A):
        cnt += int(vv)
    if cnt != N:
        print("No")
        continue
    
    print("Yes")


0