Submission #456183

#TimeUsernameProblemLanguageResultExecution timeMemory
456183grtSob (COCI19_sob)C++17
110 / 110
329 ms19088 KiB
#include <bits/stdc++.h> #define ST first #define ND second #define PB push_back using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; void solve(vi &a, vi &b, int dep) { if((int)a.size() <= 1 && (int)b.size() <= 1) { if((int)a.size() == 1 && (int)b.size() == 1) { cout << a[0] << " " << b[0] << "\n"; } return; } vi odda, evena, oddb, evenb; for(int i = 0; i < (int)a.size(); ++i) { if(a[i] & (1 << dep)) { odda.PB(a[i]); } else { evena.PB(a[i]); } } for(int i = 0; i < (int)b.size(); ++i) { if(b[i] & (1 << dep)) { oddb.PB(b[i]); } else { evenb.PB(b[i]); } } if(odda.size() != oddb.size()) { odda.PB(evena.back()); evena.pop_back(); } solve(evena, evenb, dep + 1); solve(odda, oddb, dep + 1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vi l(n), r(n); for(int i = 0; i < n; ++i) { l[i] = i; r[i] = m + i; } solve(l, r, 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...