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>
#define fi first
#define se second
using namespace std;
void solve(vector<int> &t1,vector<int> &t2,int b)
{
if(t1.size()==1)
{
cout<<t1[0]<<" "<<t2[0]<<"\n";
return;
}
int n=t1.size();
vector<int> tmp1,tmp2;
if(n%2==1 && (t2[0]&(1<<b))!=0)
{
tmp2.push_back(t2[0]);
for(int i=0;i<n;i+=2)
tmp1.push_back(t1[i]);
for(int i=1;i<n;i+=2)
tmp2.push_back(t2[i]);
solve(tmp1,tmp2,b+1);
tmp1.clear();tmp2.clear();
for(int i=1;i<n;i+=2)
tmp1.push_back(t1[i]);
for(int i=2;i<n;i+=2)
tmp2.push_back(t2[i]);
solve(tmp1,tmp2,b+1);
return;
}
bool bit=(t2[0]&(1<<b));
for(int i=0;i<n;i+=2)
tmp1.push_back(t1[i]);
for(int i=bit;i<n;i+=2)
tmp2.push_back(t2[i]);
solve(tmp1,tmp2,b+1);
tmp1.clear();tmp2.clear();
for(int i=1;i<n;i+=2)
tmp1.push_back(t1[i]);
for(int i=!bit;i<n;i+=2)
tmp2.push_back(t2[i]);
solve(tmp1,tmp2,b+1);
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
cin>>n>>m;
vector<int> t1(n),t2(n);
for(int i=0;i<n;i++)
{
t1[i]=i;
t2[i]=m+i;
}
solve(t1,t2,0);
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... |