結果
| 問題 |
No.1896 Arrays and XOR Procedure 2
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2022-04-08 22:55:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,255 bytes |
| コンパイル時間 | 1,882 ms |
| コンパイル使用メモリ | 182,724 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-28 13:52:03 |
| 合計ジャッジ時間 | 4,749 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#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;
}
houren