제출 #135792

#제출 시각아이디문제언어결과실행 시간메모리
135792amiratouSorting (IOI15_sorting)C++14
16 / 100
4 ms508 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[]) { map<int,int> pos; for (int i = 0; i < N; ++i) pos[S[i]]=i; int comp=0,idx=0; for (int i = 2; i < N; ++i) { if(pos[i]==i)continue; //cerr<<X[idx]<<","<<Y[idx++]<<"\n"; //int nb=S[X[idx]],nb2=S[Y[idx]]; swap(pos[S[X[idx]]],pos[S[Y[idx]]]); swap(S[X[idx]],S[Y[idx++]]); /*for (int j = 0; j < N; ++j) cerr<<S[j]<<" "; cerr<<"\n";*/ P[comp]=pos[i],Q[comp]=i; pos[S[i]]=pos[i]; pos[i]=i; swap(S[P[comp]],S[Q[comp]]); comp++; } if(pos[0]!=0){ swap(pos[S[X[idx]]],pos[S[Y[idx]]]); swap(S[X[idx]],S[Y[idx++]]); P[comp]=0,Q[comp]=0; comp++; if(S[0]==0)return comp; P[comp]=0,Q[comp]=1; swap(pos[0],pos[1]); swap(S[0],S[1]); comp++; } /*for (int i = idx; i < M; ++i) { swap(pos[X[i]],pos[Y[i]]); swap(S[X[i]],S[Y[i]]); }*/ /*for (int j = 0; j < N; ++j) cerr<<S[j]<<" "; cerr<<"\n";*/ return comp; }

컴파일 시 표준 에러 (stderr) 메시지

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:16:28: warning: operation on 'idx' may be undefined [-Wsequence-point]
      swap(S[X[idx]],S[Y[idx++]]);
                         ~~~^~
sorting.cpp:28:28: warning: operation on 'idx' may be undefined [-Wsequence-point]
      swap(S[X[idx]],S[Y[idx++]]);
                         ~~~^~
sorting.cpp:5:39: warning: unused parameter 'M' [-Wunused-parameter]
 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...