# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
465806 | daisy | Xor Sort (eJOI20_xorsort) | C++17 | 1 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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((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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |