# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421206 | Pbezz | Sorting (IOI15_sorting) | C++14 | 3 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 "sorting.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const ll MAXN=2e5+5;
const ll INF=1e9+7;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int i,k,R=0;
if(N==1)return 0;
/*
if(M>0 && Y[0]==1){
swap(S[0],S[1]);
for(k=0;k<N;k++){
if(S[k]==0)break;
}
P[R]=k;
Q[R]=1;
R++;
swap(S[k],S[1]);
swap(S[0],S[1]);
//agora, 1 esta em posiçao e vamos meter o 2
for(k=0;k<N;k++){
if(S[k]==1)break;
}
P[R]=k;
Q[R]=1;
R++;
swap(S[k],S[1]);
//esta tudo bem, continuar
for(i=3;i<=N;i++){//find i, send it to ith position
for(k=0;k<N;k++){
if(S[k]==i-1)break;
}
P[R]=k;
Q[R]=i-1;
R++;
swap(S[k],S[i-1]);
}
if(R%2==1){
P[R]=0;
Q[R]=0;
R++;
}
}else{//his moves are redundant
*/
for(i=0;i<N-1;i++){//find i, send it to ith position
for(k=0;k<N;k++){
if(S[k]==i)break;
}
P[R]=k;
Q[R]=i;
R++;
swap(S[k],S[i]);
}
/*
for(i=0;i<N;i++){
cout<<S[i]<<" ";
}cout<<endl;*/
//}
return R;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |