Submission #114470

#TimeUsernameProblemLanguageResultExecution timeMemory
114470arman_ferdousSorting (IOI15_sorting)C++17
0 / 100
13 ms384 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; int tmp[20010]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { for(int i = 0; i < M; i++) swap(S[X[i]], S[Y[i]]); int cur = 0, R = 0; for(int i = 0; i < N; ) { if(S[i] == i) { i++; continue; } int p = i, q = S[i]; for(int j = M-1; j > cur; j--) { if((X[j] == p && Y[j] == q) || (X[j] == q && Y[j] == p)) swap(p, q); else { if(X[j] == p) p = Y[j]; else if(Y[j] == p) p = X[j]; if(X[j] == q) q = Y[j]; else if(Y[j] == q) q = X[j]; } } P[R] = p, Q[R] = q; R++; cur++; swap(S[i], S[S[i]]); } while(R < M) { P[R] = Q[R] = 0; R++; } return R; }
#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...