Submission #531667

#TimeUsernameProblemLanguageResultExecution timeMemory
531667antonioqbabSorting (IOI15_sorting)C++14
0 / 100
1 ms300 KiB
#include <bits/stdc++.h> #include <sorting.h> using namespace std; int findSwapPairs(int n, int s[], int m, int x[], int y[], int s1[], int s2[]){ vector<int> p(n); for(int i=0;i<n;++i) p[i]=s[i]; int left=0, right=n-1; auto ok=[&](int pos){ auto p_=p; for(int i=0;i<=pos;++i) swap(p_[x[i]],p_[y[i]]); int ans = n; vector<int> seen(n); for(int i=0;i<n;++i) if(!seen[i]){ --ans; seen[i]=1; for(int j=p_[i];j!=i;j=p_[j]) seen[j]=1; } return ans <= pos+1; }; while(left<right){ int m=(left+right)/2; if(ok(m)) right = m; else left = m + 1; } return left; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:27:13: warning: declaration of 'int m' shadows a parameter [-Wshadow]
   27 |         int m=(left+right)/2;
      |             ^
sorting.cpp:6:39: note: shadowed declaration is here
    6 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int s1[], int s2[]){
      |                                   ~~~~^
sorting.cpp:6:39: warning: unused parameter 'm' [-Wunused-parameter]
sorting.cpp:6:64: warning: unused parameter 's1' [-Wunused-parameter]
    6 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int s1[], int s2[]){
      |                                                            ~~~~^~~~
sorting.cpp:6:74: warning: unused parameter 's2' [-Wunused-parameter]
    6 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int s1[], int s2[]){
      |                                                                      ~~~~^~~~
#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...