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;
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
l = m;
r = m+n-1;
for(int j=30;j>=0;j--){
if(n&(1<<j)){
if(l&(1<<j)){
for(int i=r;i>r-(1<<j);i--){
ans.push_back({i%(1<<j)+curr,i});
}
r -= (1<<j);
}
else{
for(int i=l;i<l+(1<<j);i++){
ans.push_back({i%(1<<j)+curr,i});
}
l += (1<<j);
}
curr += (1<<j);
}
}
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... |