제출 #210933

#제출 시각아이디문제언어결과실행 시간메모리
210933autumn_eel정렬하기 (IOI15_sorting)C++14
74 / 100
116 ms18040 KiB
#include "sorting.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; int s[3000],spos[3000]; int p[3000],ppos[3000]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { if(is_sorted(S,S+N))return 0; for(int R=1;R<=N;R++){ rep(i,N)p[i]=i,s[i]=S[i]; for(int i=R-1;i>=0;i--){ swap(p[X[i]],p[Y[i]]); } rep(i,N){ ppos[p[i]]=i; spos[s[i]]=i; } int g=0; rep(i,R){ swap(p[X[i]],p[Y[i]]); swap(ppos[p[X[i]]],ppos[p[Y[i]]]); swap(s[X[i]],s[Y[i]]); swap(spos[s[X[i]]],spos[s[Y[i]]]); while(g<N&&spos[g]==ppos[g])g++; if(g==N){ P[i]=Q[i]=0;continue; } int a=spos[g],b=ppos[g]; P[i]=a;Q[i]=b; swap(s[a],s[b]); swap(spos[s[a]],spos[s[b]]); } rep(i,N)assert(p[i]==i); bool ok=true; rep(i,N){ if(s[i]!=i)ok=false; } if(ok){ return R; } } return -1; }

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

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:9: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...