結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー hourenhouren
提出日時 2022-04-08 22:48:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,210 bytes
コンパイル時間 1,817 ms
コンパイル使用メモリ 181,392 KB
実行使用メモリ 5,968 KB
最終ジャッジ日時 2024-05-06 08:28:25
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 p,q,r,s;
        tie(p,q) = a.top(); tie(r,s) = b.top();
        ll x = p^s;
        if(x>p){
            sub = {2,q,r};
            b.pop();
            b.push({x,r});
        }else{
            sub = {1,q,r};
            a.pop();
            a.push({x,q});
        }
        ans.push_back(sub);
    }
    cout << cnt << '\n';
    rep(i,cnt){
        rep(j,3) cout << ans[i][j] << " ";
        cout << '\n';
    }
    return 0;
}
0