This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
int n, m;
bool ok[MAXN];
int res[MAXN];
map< int, int> mp;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int x = 20; x >= 0; x --){
int mask = (1 << x) - 1;
mp.clear();
for(int i = m; i < n + m; i ++){
if( !ok[i] )
mp[mask & i] = i;
}
for(int i = 0; i < n; i ++){
if( !ok[i] && mp[i & mask]){
res[i] = mp[i & mask];
ok[res[i]] = true, ok[i] = true;
mp[mask & i] = 0;
}
}
}
for(int i = 0; i < n; i ++)
cout << i << " " << res[i] << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |