Submission #69024

#TimeUsernameProblemLanguageResultExecution timeMemory
69024theknife2001Sorting (IOI15_sorting)C++17
20 / 100
6 ms640 KiB
#include "sorting.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; const int NN=555; int b[NN]; int n; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { n=N; for(int i=0;i<n;i++) b[S[i]]=i; int ans=0; for(int j=0;j<M;j++) { swap(S[X[j]],S[Y[j]]); b[S[X[j]]]=X[j]; b[S[Y[j]]]=Y[j]; for(int i=0;i<n;i++) { if(S[i]!=i) break; if(i==n-1) return ans; } for(int i=n-1;i>=0;i--) { if(S[i]!=i) { P[ans]=b[i]; Q[ans]=i; swap(b[i],b[S[i]]); swap(S[i],S[b[S[i]]]); ans++; break ; } } for(int i=0;i<n;i++) { if(S[i]!=i) break; if(i==n-1) return ans; } } return ans; } /* 5 3 0 4 2 1 5 0 1 0 1 0 1 0 1 0 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...