# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298494 | TMJN | Sorting (IOI15_sorting) | C++17 | 1 ms | 384 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 d=0;
for(int i=0;i<N;i++){
if(S[i]!=i)d++;
}
for(int i=0;i<M;i++){
if((d+1)/2<=i)return i;
d+=(S[X[i]]==X[i])+(S[Y[i]]==Y[i]);
swap(S[X[i]],S[Y[i]]);
d-=(S[X[i]]==X[i])+(S[Y[i]]==Y[i]);
if((d+1)/2<=i+1)return i+1;
}
return -1;
}
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... |