結果

問題 No.3184 Make Same
ユーザー karinohito
提出日時 2025-08-04 16:34:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 3,053 ms
コンパイル使用メモリ 284,280 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-04 16:34:29
合計ジャッジ時間 16,656 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll =long long;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    vector<array<ll,3>> AN;
    for(ll d=29;d>=0;d--){
        sort(A.begin(),A.end());
        if(A[0]&(1ll<<d))continue;
        for(int i=0;i<N;i++){
            if(A[i]&(1ll<<d)){
                AN.push_back({1,i,(1<<d)});
                break;
            }
            A[i]+=(1ll<<d);
        }
    }
    cout<<AN.size()<<endl;
    for(auto [l,r,v]:AN)cout<<l<<" "<<r<<" "<<v<<"\n";
}
0