# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65651 | mirbek01 | Sorting (IOI15_sorting) | C++17 | 5 ms | 640 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 pos[1000];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
for(int i = 0; i < N; i ++)
pos[S[i]] = i;
int sz = 0;
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]]);
pos[S[X[sz]]] = X[sz];
pos[S[Y[sz]]] = Y[sz];
P[sz] = pos[i], Q[sz] = i;
swap(S[i], S[pos[i]]);
pos[ S[pos[i]] ] = pos[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... |