Submission #641703

#TimeUsernameProblemLanguageResultExecution timeMemory
641703BenmathSorting (IOI15_sorting)C++14
16 / 100
3 ms340 KiB
#include<bits/stdc++.h> #include "sorting.h" using namespace std; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int n=N; int bro=0; int R=n-1; for(int i=0;i<=(n-2);i++){ swap(S[X[i]],S[Y[i]]); int loc=i; for(int j=n-2;j>i;j--){ if(X[j]==loc){ loc=Y[j]; }else{ if(Y[j]==loc){ loc=X[j]; } } } int loc1=-1; for(int j=0;j<n;j++){ if(S[j]==i){ loc1=j; break; } } if(loc1!=loc){ P[i]=loc1; Q[i]=loc; swap(S[P[i]],S[Q[i]]); }else{ P[i]=loc1; Q[i]=loc1; } } return R; } /* int main(){ } */

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:6:8: warning: unused variable 'bro' [-Wunused-variable]
    6 |    int bro=0;
      |        ^~~
sorting.cpp:4:39: warning: unused parameter 'M' [-Wunused-parameter]
    4 | 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...