Submission #1258452

#TimeUsernameProblemLanguageResultExecution timeMemory
1258452SalihSahinSob (COCI19_sob)C++20
0 / 110
1095 ms8536 KiB
#include "bits/stdc++.h" #define pb push_back #define int long long using namespace std; const int inf = 1e15; const int N = 1e6 + 5; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n, m; cin>>n>>m; vector<int> ans(n); for(int i = 0; i < n; i++){ ans[i] = i; } for(int i = 0; i < 21; i++){ int bt = (1 << i); vector<int> updans = ans; vector<int> type[2][2]; for(int j = 0; j < n; j++){ type[(j&bt) > 0][(updans[j]&bt) > 0].pb(j); } if((m&bt)){ int ind = 0; for(auto itr: type[1][1]){ swap(updans[itr], updans[type[0][0][ind]]); ind++; } for(int j = 0; j < n; j++){ updans[j] += bt; } } else{ for(int j = 0; j < n; j++){ int a = ((j&bt) > 0); int b = ((updans[j]&bt) > 0); if(!a) continue; if(a == 1 && b == 0){ int icer = j & ((1 << i) - 1); for(int k = 0; k < j; k++){ int icerk = k & ((1 << i) - 1); if(j & icerk != icerk) continue; if(k & icer != icer) continue; int ain = (((k)&bt) > 0); int bin = ((updans[k]&bt) > 0); if(ain == 0 && bin == 1){ swap(updans[j], updans[k]); break; } } } } } swap(updans, ans); } for(int i = 0; i < n; i++){ cout<<i<<" "<<ans[i]<<endl; } 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...