Submission #464484

#TimeUsernameProblemLanguageResultExecution timeMemory
464484JasiekstrzSob (COCI19_sob)C++17
110 / 110
252 ms15164 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...