# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
465804 | 2021-08-16T18:58:35 Z | daisy | Xor Sort (eJOI20_xorsort) | C++17 | 1 ms | 204 KB |
#include<iostream> #include<vector> #define endl '\n' using namespace std; pair<int,int> m[1005]; vector< pair<int,int> > v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,s,b=0; cin>>n>>s; for(int i=1;i<=n;i++){ cin>>m[i].first; m[i].second=i; } for(int i=(1<<20);i>=1;i/=2) { for(int j=1;j<n;j++) { if(((i&(m[j].first)) && m[j+1].first<=m[j].first)) { if(!(i&(m[j+1].first))) { v.push_back({j+1,j}); (m[j+1].first)^=(m[j].first); } v.push_back({j,j+1}); (m[j].first)^=(m[j+1].first); } } //for(int i=1;i<=n;i++) cout<<m[i].first<<" ";cout<<endl; } cout<<v.size()<<endl; for(int i=0;i<v.size();i++) { cout<<v[i].first<<" "<<v[i].second<<endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Not sorted |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Not sorted |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Not sorted |
3 | Halted | 0 ms | 0 KB | - |