# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65669 | mirbek01 | Sorting (IOI15_sorting) | C++17 | 3 ms | 768 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>
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int sz = 0;
set <int> st;
for(int i = N - 1; i >= 0; i --)
{
assert( S[i] >= 0 && S[i] < N );
st.insert(S[i]);
}
assert(st.size() == N && M == N * N);
for(int i = 0; i < M; i ++){
assert(!X[i] && !Y[i]);
}
for(int i = N - 1; i > 0; i --){
bool fl = 1;
for(int j = 0; j < N; j ++){
if(j != S[j]) fl = 0;
}
if(fl) break;
// swap(S[X[sz]], S[Y[sz]]);
int pos;
for(int j = 0; j < N; j ++){
if(S[j] == i){
pos = j;
break;
}
}
swap(S[pos], S[i]);
P[sz] = pos, Q[sz] = i;
sz ++;
}
return sz;
}
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... |