Submission #1053704

#TimeUsernameProblemLanguageResultExecution timeMemory
1053704XJP12Sorting (IOI15_sorting)C++14
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> #include "sorting.h" using namespace std; typedef vector<int> vi; int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) { int r=0; if(y[0]==1){ for(int i=0; i<n; i++){ swap(s[1], s[0]); r++; /*for(int j=0; j<n; j++){ cout<<s[j]<<" "; }*/ // cout<<endl; for(int j=0; j<n; j++){ if(s[j]==i){ if(s[i]==0 && i==1){ p[i]=j; q[i]=i-1; swap(s[i-1], s[j]); }else{ p[i]=j; q[i]=i; swap(s[i], s[j]); } break; } } /* for(int j=0; j<n; j++){ cout<<s[j]<<" "; } cout<<endl<<endl;*/ } if(s[1]!=1 && s[0]!=0){ p[r]=0; q[r]=1; r++; } /*for(int i=0; i<r; i++){ cout<<p[i]<<" "<<q[i]<<endl; }*/ }else{ for(int i=0; i<n; i++){ r++; for(int j=0; j<n; j++){ if(s[j]==i){ p[i]=j; q[i]=i; swap(s[i], s[j]); break; } } /* for(int j=0; j<n; j++){ cout<<s[j]<<" "; } cout<<endl;*/ } /* for(int i=0; i<r; i++){ cout<<p[i]<<" "<<q[i]<<endl; }*/ } return r; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:5:39: warning: unused parameter 'm' [-Wunused-parameter]
    5 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
      |                                   ~~~~^
sorting.cpp:5:46: warning: unused parameter 'x' [-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...