# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126183 | SOIVIEONE | Sorting (IOI15_sorting) | C++14 | 5 ms | 380 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 id[2222222];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
for(int i = 0; i < N; i ++)
id[S[i]] = i;
int ans = 0;
for(int i = 0; i < N; i ++)
{
int flag = 0;
for(int j = 1; j < N; j ++)
if(S[j] < S[j - 1])
flag = 1;
if(!flag)
break;
if(Y[i])
{
swap(S[1], S[0]);
id[S[1]] = 1;
id[S[0]] = 0;
}
swap(S[id[i]], S[i]);
P[i] = id[i]; Q[i] = i;
id[S[id[i]]] = id[i];
id[i] = i;
ans = i+1;
}
if(S[1] < S[0])
{
ans = N+1;
P[N] = 0; Q[N] = 1;
}
return ans;
}
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... |