# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1018549 |
2024-07-10T06:43:31 Z |
huutuan |
Sorting (IOI15_sorting) |
C++14 |
|
1 ms |
2396 KB |
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
int a[200010], pos[200010], s[200010];
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;
if (is_sorted(s, s+N)) return 0;
for (int _=0; _<M; ++_){
for (int i=0; i<N; ++i) s[i]=S[i];
iota(a, a+N, 0);
for (int i=_; i>=0; --i) swap(a[X[i]], a[Y[i]]);
for (int i=0; i<M; ++i){
P[i]=Q[i]=0;
swap(a[X[i]], a[Y[i]]);
swap(s[X[i]], s[Y[i]]);
pos[s[X[i]]]=X[i];
pos[s[Y[i]]]=Y[i];
for (int j=0; j<N; ++j) if (a[j]!=s[j]){
int k=pos[a[j]];
P[i]=j, Q[i]=k;
break;
}
swap(s[P[i]], s[Q[i]]);
pos[s[P[i]]]=P[i];
pos[s[Q[i]]]=Q[i];
}
return _+1;
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |