Submission #100614

#TimeUsernameProblemLanguageResultExecution timeMemory
100614luciocfSorting (IOI15_sorting)C++14
0 / 100
2 ms384 KiB
#include <bits/stdc++.h> #include "sorting.h" using namespace std; const int maxn = 2e5+10; int pos[maxn]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { for (int i = 0; i < N; i++) { if (S[i] != i) break; if (i == N-1) return 0; } for (int i = 0; i < N; i++) pos[S[i]] = i; if (Y[0] == 0) { for (int i = 0; i < N; i++) { int j = S[i]; P[i] = pos[i], Q[i] = i; S[pos[i]] = j, S[i] = i; pos[j] = pos[i], pos[i] = i; } return N; } pos[S[0]] = 1, pos[S[1]] = 0; swap(S[0], S[1]); int j = S[1]; P[0] = pos[0], Q[0] = 1; S[pos[0]] = j, S[1] = 0; pos[j] = pos[0], pos[0] = 1; pos[S[0]] = 1, pos[S[1]] = 0; swap(S[0], S[1]); j = S[1]; P[1] = pos[1], Q[1] = 1; S[pos[1]] = j, S[1] = 1; pos[j] = pos[1], pos[1] = 1; for (int i = 2; i < N; i++) { j = S[i]; P[i] = pos[i], Q[i] = i; S[pos[i]] = j, S[i] = i; pos[j] = pos[i], pos[i] = i; } if (N&1) { P[N] = 0, Q[N] = 0; return N+1; } return N; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:10:39: warning: unused parameter 'M' [-Wunused-parameter]
 int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) 
                                       ^
sorting.cpp:10:48: warning: unused parameter 'X' [-Wunused-parameter]
 int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) 
                                                ^
#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...