Submission #135299

#TimeUsernameProblemLanguageResultExecution timeMemory
135299BoxworldSorting (IOI15_sorting)C++14
20 / 100
3 ms376 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 ooo=1; for (int i=0;i<N;i++) if (S[i]!=i)ooo=0; if (ooo)return 0; for (int i=0;i<M;i++){ int p1=X[i],p2=Y[i],start=0,ok=1; swap(S[p1],S[p2]); // printf("Now:");for (int i=0;i<N;i++)printf("%d ",S[i]);printf("\n"); if (p1+p2==1&&S[p1]+S[p2]==1)start=2; for (int j=start;j<N;j++) if (S[j]!=j){ P[i]=j;Q[i]=S[j]; // printf("SWAP#%d:S[%d]=%d S[%d]=%d\nNOW:",i,j,S[j],S[j],S[S[j]]); swap(S[j],S[S[j]]); // for (int i=0;i<N;i++)printf("%d ",S[i]);printf("\n"); ok=0; int oo=1; for (int i=0;i<N;i++) if (S[i]!=i){oo=0;break;} if (oo)return i+1; break; } if (ok){ if (S[0]>S[1]){ P[i]=0;Q[i]=1; // printf("SWAP%d:S[%d]=%d S[%d]=%d\nNOW:",i,0,S[0],1,S[1]); swap(S[0],S[1]); // for (int j=0;j<N;i++)printf("%d ",S[i]);printf("\n"); return i+1; }else { P[i]=Q[i]=0; // printf("SWAP#%d:S[%d]=%d S[%d]=%d\nNOW:",i,0,0,0,0); return i+1; } } } }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:23:22: warning: declaration of 'i' shadows a previous local [-Wshadow]
             for (int i=0;i<N;i++)
                      ^
sorting.cpp:10:14: note: shadowed declaration is here
     for (int i=0;i<M;i++){
              ^
sorting.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...