結果

問題 No.3184 Make Same
ユーザー norioc
提出日時 2025-06-21 14:28:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 82,776 KB
実行使用メモリ 122,680 KB
最終ジャッジ日時 2025-06-21 14:28:30
合計ジャッジ時間 11,721 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

def bsr(x: int) -> int:
    """1 が立っている最上位ビットの位置を返す (0-indexed)"""
    assert x != 0
    return x.bit_length() - 1


N = int(input())
A = list(map(int, input().split()))

ma = max(A)
if ma == 0:
    print(0)
    exit()

xs = A[:]
ans = []
for i in reversed(range(bsr(ma)+1)):
    if xs[0] & (1 << i): continue

    ind = N
    for j in range(N):
        if xs[j] & (1 << i):
            ind = j
            break

        xs[j] |= (1 << i)

    ans.append((i, ind))
    xs.sort()

print(len(ans))
for p, r in ans:
    print(1, r, 1 << p)
0