結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー hourenhouren
提出日時 2022-04-08 22:55:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,255 bytes
コンパイル時間 1,512 ms
コンパイル使用メモリ 180,552 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-19 01:27:14
合計ジャッジ時間 6,303 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 4 ms
4,388 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 4 ms
4,384 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    priority_queue<P> a;
    priority_queue<P,vector<P>,greater<P>> b;
    rep(i,n){
        ll x;
        cin >> x;
        a.push({x,i+1});
    }
    rep(i,n){
        ll x;
        cin >> x;
        b.push({x,i+1});
    }
    vector<vector<ll>> ans;
    int cnt = 0;
    vector<ll> sub(3);
    while(a.top().first>=b.top().first){
        cnt++;
        ll p1,p2,q1,q2;
        tie(p1,p2) = a.top(); tie(q1,q2) = b.top();
        ll x = p1^q1;
        if(x>p1){
            sub = {2,p2,q2};
            b.pop();
            b.push({x,q2});
        }else{
            sub = {1,p2,q2};
            a.pop();
            a.push({x,p2});
        }
        ans.push_back(sub);
    }
    cout << cnt << '\n';
    rep(i,cnt){
        rep(j,3) cout << ans[i][j] << " ";
        cout << '\n';
    }
    while(cnt>10000) cnt++;
    return 0;
}
0