Submission #468852

#TimeUsernameProblemLanguageResultExecution timeMemory
468852mychecksedadXor Sort (eJOI20_xorsort)C++17
0 / 100
0 ms204 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back int main(){ cin.tie(0); ios::sync_with_stdio(0); int n, s, arr[1010]; cin >> n >> s; for(int i = 1; i <= n; i++) cin >> arr[i]; vector<pair<int, int>> ans; if(s == 1){ }else{ for(int bit = 20; bit >= 0; bit--){ for(int i = 1; i < n; i++){ if((1<<bit)&arr[i]){ if((1<<bit)&(arr[i + 1])){ ans.pb({i, i+1}); arr[i] ^= (1<<bit); }else{ ans.pb({i+1, i}); ans.pb({i, i+1}); arr[i + 1] ^= (1<<bit); arr[i] ^= (1<<bit); } } } } // for(int i = 1; i <= n; i++) cout << arr[i] << '\n'; } cout << ans.size() << '\n'; for(auto k: ans) cout << k.first << ' ' << k.second << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...