Submission #65659

#TimeUsernameProblemLanguageResultExecution timeMemory
65659mirbek01Sorting (IOI15_sorting)C++17
0 / 100
6 ms384 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 sz = 0; for(int i = N - 1; i > 0; i --){ swap(S[X[sz]], S[Y[sz]]); int pos; for(int j = 0; j < N; j ++){ if(S[j] == i){ pos = j; break; } } P[sz] = pos, Q[sz] = i; swap(S[pos], S[i]); sz ++; bool fl = 1; for(int j = 0; j < N; j ++){ if(j != S[j]) fl = 0; } if(fl) break; } return sz; }

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:19:19: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
             P[sz] = pos, Q[sz] = i;
             ~~~~~~^~~~~
#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...