Submission #94898

#TimeUsernameProblemLanguageResultExecution timeMemory
94898someone_aaSorting (IOI15_sorting)C++17
20 / 100
12 ms640 KiB
#include <bits/stdc++.h> #include "sorting.h" using namespace std; const int maxn = 110; int value[maxn], ind[maxn]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int br = 0; for(int i=0;i<N;i++) { value[i] = S[i]; ind[S[i]] = i; } for(int i=0;i<M;i++) { int x = 0; for(int j=0;j<N;j++) { if(value[j] == j) x++; } if(x == N) break; ind[value[X[i]]] = Y[i]; ind[value[Y[i]]] = X[i]; swap(value[X[i]], value[Y[i]]); bool swaped = false; for(int i=N-1;i>=0;i--) { if(value[i] == i) continue; P[br] = i; Q[br] = ind[i]; ind[value[i]] = ind[i]; value[ind[i]] = value[i]; value[i] = i; ind[i] = i; br++; swaped = true; break; } if(!swaped) { P[br] = X[i]; Q[br] = Y[i]; br++; } } return br; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:31:17: warning: declaration of 'i' shadows a previous local [-Wshadow]
         for(int i=N-1;i>=0;i--) {
                 ^
sorting.cpp:15:13: note: shadowed declaration is here
     for(int i=0;i<M;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...