# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
71653 |
2018-08-25T09:52:01 Z |
SmsS |
Sorting (IOI15_sorting) |
C++14 |
|
4 ms |
640 KB |
#include<bits/stdc++.h>
using namespace std;
#define for2(a,b,c) for(int a=b;a<c;a++)
#include "sorting.h"
int findSwapPairs(int n, int s[], int M, int X[], int Y[], int P[], int Q[]) {
vector<int> S(n);
for2(i,0,n) S[i] = s[i];
int r = 0;
for(int cur = n-1; cur >= 0; cur--){
if(is_sorted(S.begin(),S.end())){
break;
}
swap(S[X[r]],S[Y[r]]);
for2(i,0,n) if(S[i] == cur){
P[r] = min(i,cur);
Q[r] = max(i,cur);
swap(S[i],S[cur]);
r++;
break;
}
}
if(S[0] != 0){
swap(S[X[r]],S[Y[r]]);
P[r] =Q[r] = 0;
r++;
}
if(r > M){
assert(1);
assert(0);
}
if(!is_sorted(S.begin(),S.end())) { assert(0); assert(1);}
return r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |