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;
#define int ll
int n,m,l,r,curr;
vector<vector<int>> ans;
vector<int> a;
vector<int> b[3000005];
signed main(){
//ios::sync_with_stdio(false);
//cin.tie(NULL);
cin >> n >> m;
for(int i=0;i<=n-1;i++){
a.push_back(i);
}
for(int i=m;i<=m+n-1;i++){
b[i].push_back(i);
}
for(int j=20;j>=0;j--){
while(a.size()>0 and a.back()&(1<<j)){
int x = a.back();
a.pop_back();
int y = b[x].back();
b[x].pop_back();
ans.push_back({x,y});
}
for(int i=(1<<j);i<(1<<(j+1));i++){
for(int k:b[i]){
b[i-(1<<j)].push_back(k);
}
b[i].clear();
}
}
ans.push_back({a.back(),b[0][0]});
for(vector<int> i:ans){
cout << i[0] << " " << i[1] << "\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... |