# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1044862 | 2024-08-05T14:12:43 Z | mar | Xor Sort (eJOI20_xorsort) | C++14 | 1 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; int arr[10008]; int main() { int n,s; cin>>n>>s; for(int i=0; i < n; i++) { cin>>arr[i]; } vector<pair<int,int>> ans; if(s==1) { for(int bit = 22; bit >= 0; bit--){ for(int i = 0; i+1 < n; i++){ if(arr[i]&(1LL<<bit)){ if (arr[i+1]&(1LL<<bit)){ ans.push_back({i+1,i+2}); arr[i]^=arr[i+1]; } else { ans.push_back({i+2,i+1}); ans.push_back({i+1,i+2}); arr[i+1]^=arr[i]; arr[i]^=arr[i+1]; } } } if((n>=1) && (arr[n-1]&(1LL<<bit))){ n--; } } }else{ } cout<<ans.size()<<endl; for (int i = 0; i < ans.size(); i++){ cout<<ans[i].first<<" "<<ans[i].second<<endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 1 ms | 348 KB | Not sorted |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 1 ms | 348 KB | Not sorted |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Not sorted |
2 | Halted | 0 ms | 0 KB | - |