結果

問題 No.3531 Erase Pair
コンテスト
ユーザー kidodesu
提出日時 2026-05-04 23:54:31
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 1,323 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 285 ms
コンパイル使用メモリ 85,820 KB
実行使用メモリ 83,692 KB
最終ジャッジ日時 2026-05-04 23:54:45
合計ジャッジ時間 13,674 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other RE * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    def check(D):
        d0 = D[0]
        n = len(D)
        E = set(D)
        E = list(E)
        E.sort()
        if len(E) == 1:
            return 0
        elif E == [1, 2]:
            return 0
        elif E == [1, 2, 3]:
            if D[-3:] == [1, 2, 3]:
                return 0
            else:
                assert 0
                return 1
        else:
            return 1
    n = int(input())
    A = list(map(int, input().split()))
    c0 = 0
    for a in A:
        if a == 0: c0 += 1
    if 2 <= c0:
        return 0
    elif c0 == 1 and not n % 2:
        return 0
    elif not (c0 == 1 and n % 2):
        return 1
    B = []
    C = []
    for a in A:
        if a < 0:
            B.append(-a)
        elif 0 < a:
            C.append(a)
    B.sort()
    C.sort()
    if not len(B) % 2:
        return 1
    if B[0] != C[0]:
        return 1
    if B[0] != B[len(B)//2]:
        return 1
    if C[0] != C[len(C)//2]:
        return 1
    b = B[0]
    for i in range(len(B)):
        if B[i] % b:
            return 1
        B[i] //= b
    for i in range(len(C)):
        if C[i] % b:
            return 1
        C[i] //= b
    if B[-1] == B[0] and C[-1] == C[0]:
        return 0
    return check(B) or check(C)
for _ in range(int(input())):
    print("Yes" if main() else "No")
0