# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1102974 |
2024-10-19T09:44:59 Z |
Pioneer |
Sorting (IOI15_sorting) |
C++17 |
|
21 ms |
592 KB |
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX=100000;
int n,m,x[MAX],y[MAX];
int s[MAX];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
n=N,m=M;
for(int i=0;i<M;i++)x[i]=X[i],y[i]=Y[i];
for(int i=0;i<N;i++)s[i]=S[i];
vector<int> v(n),need(n);
vector<pair<int,int>> swaps;
for(int i=0;i<n;i++)v[i]=s[i],need[i]=i;
for(int i=0;i<m;i++){
swap(v[x[i]],v[y[i]]);
vector<int> tov=need;
for(int j=i+1;j<m;j++){
swap(tov[x[j]],tov[y[j]]);
}
bool ok=0;
for(int k=0;k<n;k++){
if(tov[k]!=v[k]){
for(int j=0;j<n;j++){
if(tov[j]==v[k]){
ok=1;
swaps.push_back({k,j});
swap(v[k],v[j]);
break;
}
}
if(ok)break;
}
}
// tov=need;
// for(int j=i+1;j<m;j++){
// swap(tov[x[j]],tov[y[j]]);
// }
// for(int i=0;i<n;i++)cout<<tov[i]<<" "<<v[i]<<"\n";
// cout<<"\n";
if(!ok)swaps.push_back({0,0});
}
// cout<<"\n";
assert(v==need);
for(int i=0;i<m;i++){
P[i]=swaps[i].first;
Q[i]=swaps[i].second;
}
return M;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
5 ms |
336 KB |
Output is correct |
4 |
Correct |
5 ms |
336 KB |
Output is correct |
5 |
Correct |
5 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |