Submission #440868

# Submission time Handle Problem Language Result Execution time Memory
440868 2021-07-03T11:56:46 Z MrDeboo Xor Sort (eJOI20_xorsort) C++17
0 / 100
589 ms 524292 KB
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define endl '\n'
using namespace std;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,s;
    cin>>n>>s;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    vector<pair<int,int>>vct;
    bool bl;
    do{
        bl=false;
        for(int i=0;i<n;i++){
            if(i>0&&((arr[i]<=arr[i-1]&&(arr[i]^arr[i-1])>arr[i])||(i<n-1&&arr[i]>=arr[i+1]&&(arr[i]^arr[i-1])<arr[i]))){vct.push_back({i+1,i});bl=true;arr[i]^=arr[i-1];}
            if(i<n-1&&((i>0&&arr[i]<=arr[i-1]&&(arr[i]^arr[i+1])>arr[i])||(arr[i]>=arr[i+1]&&(arr[i]^arr[i+1])<arr[i]))){vct.push_back({i+1,i+2});bl=true;arr[i]^=arr[i+1];}
        }
        //for(int i=0;i<n;i++)cout<<arr[i]<<' ';
        //cout<<endl;
    }while(bl);
    cout<<vct.size()<<endl;
    for(auto i:vct)cout<<i.first<<' '<<i.second<<endl;
}
//5 1 1 1 6 5
//5 5 6 5 6
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 578 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 578 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 589 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -