Submission #1085413

#TimeUsernameProblemLanguageResultExecution timeMemory
1085413guagua0407Sorting (IOI15_sorting)C++17
0 / 100
2 ms604 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; vector<int> p; vector<int> x,y; vector<pair<int,int>> vec; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { if(n==1) return 0; n=N; m=M; p.resize(n); x.resize(m); y.resize(m); for(int i=0;i<n;i++){ p[i]=S[i]; } for(int i=0;i<m;i++){ x[i]=X[i]; y[i]=Y[i]; } int cnt=0; for(int i=2;i<n;i++){ if(p[i]==0){ swap(p[0],p[1]); swap(p[0],p[i]); P[cnt]=0; Q[cnt]=i; cnt++; break; } } for(int i=2;i<n;i++){ if(p[i]==1){ swap(p[0],p[1]); if(p[0]!=0) swap(p[0],p[i]),P[cnt]=0; else swap(p[1],p[i]),P[cnt]=1; Q[cnt]=i; cnt++; break; } } for(int i=2;i<n;i++){ for(int j=i+1;j<n;j++){ if(S[j]==i){ swap(p[0],p[1]); swap(S[i],S[j]); P[cnt]=i; Q[cnt]=j; cnt++; break; } } } return (p[0]==0?cnt:cnt+1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...