# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
543352 |
2022-03-30T11:11:30 Z |
cig32 |
Sorting (IOI15_sorting) |
C++17 |
|
2 ms |
468 KB |
#ifdef ONLINE_JUDGE
#include "sorting.h"
#endif
#include "bits/stdc++.h"
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]);
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
bool sorted =1 ;
for(int i=1; i<N; i++) {
sorted &= (S[i] >= S[i-1]);
}
if(sorted) return 0;
int T[N];
for(int i=0; i<N; i++) T[i] = S[i];
sort(T, T + N);
for(int i=0; i<M; i++) {
if(X[i] > Y[i]) swap(X[i], Y[i]);
if(S[X[i]] > S[Y[i]]) {
swap(S[X[i]], S[Y[i]]);
for(int j=0; j<N; j++) {
if(S[j] != T[j]) {
for(int k=0; k<N; k++) {
if(S[k] == T[j]) {
P[i] = j, Q[i] = k;
swap(S[j], S[k]);
break;
}
}
break;
}
}
}
else {
P[i] = X[i], Q[i] = Y[i];
}
}
#ifndef ONLINE_JUDGE
for(int i=0; i<N; i++) cout << S[i] << ' ';
cout <<'\n';
#endif
return M;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Expected EOLN |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Expected EOLN |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Expected EOLN |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Expected EOLN |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |