Submission #117759

#TimeUsernameProblemLanguageResultExecution timeMemory
117759zubecSorting (IOI15_sorting)C++14
20 / 100
3 ms384 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; int pos[200100]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int ans = 0; for (int i = 0; i < N; i++){ pos[S[i]] = i; } for (int i = 0; i < N; i++){ if (S[i] != i){ int x = pos[i]; //cout << "kek " << i << ' ' << x << endl; /*pos[S[x]] = x; pos[i] = i;*/ swap(S[i], S[x]); swap(pos[i], pos[S[x]]); P[ans] = i; Q[ans] = x; ++ans; } } return ans; } /** 5 3 0 4 2 1 5 1 1 4 0 2 3 1 4 0 4 */

Compilation message (stderr)

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