# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
456296 | urosk | Xor Sort (eJOI20_xorsort) | C++14 | 1 ms | 320 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.
///sat
#include <chrono>
using namespace std::chrono;
#define vremestart auto start = high_resolution_clock::now();
#define vremeend auto stop = high_resolution_clock::now();
#define vremeispis auto duration = duration_cast<microseconds>(stop - start); cout << duration.count() << endl;
///sat
#define here cerr<<"---------------------------\n"
#define popcount(x) __builtin_popcount(x) ///broj bitova
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define th third
#define fo fourth
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
void setIO(string inoutname)
{
freopen((inoutname+".in").c_str(),"r",stdin);
freopen((inoutname+".out").c_str(),"w",stdout);
}
ll gcd(ll a, ll b)
{
if(b==0) return a;
if(a==0) return b;
if(a>=b) return gcd(a%b,b);
return gcd(a,b%a);
}
#define maxn 1005
ll n,s;
ll a[maxn][25];
void xor_(ll i,ll j){
for(ll k = 0;k<25;k++){
a[i][k]^=a[j][k];
}
return;
}
void tc(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
cin >> n >> s;
ll x;
for(ll i = 1;i<=n;i++){
cin >> x;
ll j = 0;
while(x>0){
ll f = x%2;
a[i][j] = f;
j++;
x/=2;
}
}
/*for(ll i = 1;i<=n;i++){
for(ll j = 19;j>=0;j--) cout<<a[i][j];
cout<<endl;
}*/
vector<pll> ans;
for(ll i = 19;i>=0;i--){
for(ll j = 1;j<n;j++){
if(a[j][i]==1){
if(a[j+1][i]==1){
xor_(j,j+1);
ans.pb({j,j+1});
}else{
xor_(j+1,j);
ans.pb({j+1,j});
}
}
}
}
cout<<sz(ans)<<endl;
for(pll p : ans){
cout<<p.fi<< " "<<p.sc<<endl;
}
/*for(ll i = 1;i<=n;i++){
for(ll j = 19;j>=0;j--) cout<<a[i][j];
cout<<endl;
}*/
}
int main(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
//setIO("lol");
int t; t = 1;
while(t--){
tc();
}
return 0;
}
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... |