Submission #440847

# Submission time Handle Problem Language Result Execution time Memory
440847 2021-07-03T11:24:20 Z MrDeboo Xor Sort (eJOI20_xorsort) C++17
0 / 100
9 ms 1484 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<n-1&&(arr[i]^arr[i+1])<arr[i]){arr[i]^=arr[i+1];vct.push_back({i+1,i+2});bl=true;}
            if(i>0&&(((arr[i]^arr[i-1])>arr[i])||((arr[i]^arr[i-1])<arr[i]&&arr[i]>=arr[i+1]))){arr[i]^=arr[i-1];vct.push_back({i+1,i});bl=true;}
        }
    }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 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Not sorted
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Not sorted
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Incorrect 9 ms 1484 KB Integer 42173 violates the range [0, 40000]
6 Halted 0 ms 0 KB -