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;
//#define int long long
#define X first
#define Y second
int n;int m;
int vis[1000006];
signed main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
vector<pair<int,int>>ans;
cin>>n>>m;
int lst=0;
for(int i=n-1;i>=0;i--){
if(lst!=0&&vis[lst-1]==0&&((i&(lst-1+m))==i) ){
lst--;
//ans.push_back({i,lst+m});
cout<<i<<" "<<lst+m<<endl;
vis[lst]=1;
continue;
}
for(int j=0;j<=n-1;j++){
if(vis[j]){continue;}
if( ((i&(j+m))==i) ){
cout<<i<<" "<<j+m<<endl;
lst=j;
vis[j]=1;
break;
}
}
}
}
# | 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... |