Submission #720136

#TimeUsernameProblemLanguageResultExecution timeMemory
720136fuad27Xor Sort (eJOI20_xorsort)C++17
0 / 100
1 ms296 KiB
#include<bits/stdc++.h> using namespace std; int main () { int n, s; cin >> n >> s; int a[n]; for(int i = 0;i<n;i++)cin >> a[i]; if(s==2) { vector<pair<int,int>> op; for(int i = 19;i>=0;i--) { for(int j = 1;j<n;j++) { if((a[j]&(1<<i))==0 and (a[j-1]&(1<<i))!=0) { a[j]^=a[j-1]; op.push_back({j,j-1}); } if((a[j-1]&(1<<i))!=0) { if((a[j-1]^a[j])<a[j-1]) { a[j-1]^=a[j]; op.push_back({j-1,j}); } } } } cout << op.size() << "\n"; for(auto i:op) { cout << i.first << " " << i.second << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...