結果

問題 No.3184 Make Same
ユーザー detteiuu
提出日時 2025-06-20 21:45:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 82,640 KB
実行使用メモリ 259,720 KB
最終ジャッジ日時 2025-06-20 21:45:41
合計ジャッジ時間 15,537 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right

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

ans = []
for i in reversed(range(30)):
    b = bisect_left(A, ((1<<30)-1)-((1<<i)-1))
    if b == 0:
        continue
    L, R = A[:b], A[b:]
    ans.append((1, len(L), 1<<i))
    for j in range(len(L)):
        L[j] += 1<<i
    A = []
    idxL, idxR = 0, 0
    while idxL < len(L) or idxR < len(R):
        if idxR == len(R):
            A.append(L[idxL])
            idxL += 1
        elif idxL == len(L):
            A.append(R[idxR])
            idxR += 1
        else:
            if L[idxL] <= R[idxR]:
                A.append(L[idxL])
                idxL += 1
            else:
                A.append(R[idxR])
                idxR += 1

print(len(ans))
for a in ans:
    print(*a)
0