Submission #1122134

#TimeUsernameProblemLanguageResultExecution timeMemory
1122134epicci23Sorting (IOI15_sorting)C++17
16 / 100
2 ms340 KiB
#include "bits/stdc++.h" #include "sorting.h" #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() using namespace std; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]){ vector<int> ar(N); for(int i = 0 ; i < N ; i++) ar[i] = S[i]; for(int i = N - 1; i >= 0 ; i--){ if(is_sorted(all(ar))) return N-1-i; swap(ar[X[N -1 -i]],ar[Y[N -1 -i]]); for(int j = 0; j < N ; j++){ if(ar[j] == i){ P[N -1 -i] = j; Q[N -1 -i] = i; swap(ar[i], ar[j]); break; } } } return N; }

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]
    7 | 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...