Submission #439885

#TimeUsernameProblemLanguageResultExecution timeMemory
439885SaynaaSob (COCI19_sob)C++14
110 / 110
687 ms57136 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e6 + 5; int n, m; bool ok[MAXN]; int res[MAXN]; map< int, int> mp; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int x = 20; x >= 0; x --){ int mask = (1 << x) - 1; mp.clear(); for(int i = m; i < n + m; i ++){ if( !ok[i] ) mp[mask & i] = i; } for(int i = 0; i < n; i ++){ if( !ok[i] && mp[i & mask]){ res[i] = mp[i & mask]; ok[res[i]] = true, ok[i] = true; mp[mask & i] = 0; } } } for(int i = 0; i < n; i ++) cout << i << " " << res[i] << '\n'; 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...