Submission #298494

#TimeUsernameProblemLanguageResultExecution timeMemory
298494TMJNSorting (IOI15_sorting)C++17
0 / 100
1 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 d=0; for(int i=0;i<N;i++){ if(S[i]!=i)d++; } for(int i=0;i<M;i++){ if((d+1)/2<=i)return i; d+=(S[X[i]]==X[i])+(S[Y[i]]==Y[i]); swap(S[X[i]],S[Y[i]]); d-=(S[X[i]]==X[i])+(S[Y[i]]==Y[i]); if((d+1)/2<=i+1)return i+1; } return -1; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:5:64: warning: unused parameter 'P' [-Wunused-parameter]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                            ~~~~^~~
sorting.cpp:5:73: warning: unused parameter 'Q' [-Wunused-parameter]
    5 | 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...