Submission #135839

#TimeUsernameProblemLanguageResultExecution timeMemory
135839AyaBenSaadSorting (IOI15_sorting)C++14
0 / 100
3 ms504 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int r = 0; pair <int, int> t[N], a[N]; for (int i = 0; i < N; i++) t[i] = {S[i], i}; sort (t, t+N); for (int i = 0; i < N; i++) { a[t[i].second] = {t[i].second, i}; } int id = 0; while (id < N) { while (a[id].second != id) { swap (a[id], a[a[id].second]); P[r] = id; Q[r] = a[id].second; r++; } id++; } return r; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:6: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:6: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:6: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...