Submission #543356

#TimeUsernameProblemLanguageResultExecution timeMemory
543356cig32Sorting (IOI15_sorting)C++17
0 / 100
2 ms340 KiB
#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++) { P[i] = 0, Q[i] = 0; 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]; } } return M; }
#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...