# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287357 | AaronNaidu | Sorting (IOI15_sorting) | C++14 | 4 ms | 512 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 <bits/stdc++.h>
using namespace std;
vector<int> s;
int n;
bool sorted() {
for (int i = 0; i < n; i++)
{
if (s[i] != i)
{
return false;
}
}
return true;
}
int findSwapPairs(int N,int S[],int M, int X[],int Y[],int P[],int Q[]) {
n = N;
for (int i = 0; i < N; i++)
{
s.push_back(S[i]);
}
for (int i = N-1; i >= 0; i--)
{
if (sorted())
{
return N-1-i;
}
swap(s[X[N-1-i]], s[Y[N-1-i]]);
for (int j = 0; j < N-1; j++)
{
if (s[j] == j)
{
P[N-1-i] = j;
Q[N-1-i] = i;
swap(s[j], s[i]);
}
}
}
return N;
}
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... |