제출 #298509

#제출 시각아이디문제언어결과실행 시간메모리
298509TMJN정렬하기 (IOI15_sorting)C++17
0 / 100
2 ms488 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; int s[200000]; int k[200000]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int d=0; for(int i=0;i<N;i++){ if(S[i]!=i)d++; } int l,r; l=-1; r=M; while(l+1!=r){ int m=(l+r)/2; for(int i=0;i<N;i++){ s[i]=S[i]; } for(int i=0;i<=m;i++){ swap(s[X[i]],s[Y[i]]); } for(int i=0;i<N;i++){ k[s[i]]=i; } int c=0; for(int i=0;i<N;i++){ if(s[i]!=i){ c++; swap(s[i],s[k[i]]); swap(k[i],k[s[k[i]]]); } } if(c<=m+1){ r=m; } else{ l=m; } } for(int i=0;i<N;i++){ s[i]=S[i]; } for(int i=0;i<=r;i++){ swap(s[X[i]],s[Y[i]]); } for(int i=0;i<N;i++){ k[s[i]]=i; } vector<pair<int,int>>vp; for(int i=0;i<N;i++){ if(s[i]!=i){ vp.push_back({s[i],s[k[i]]}); swap(s[i],s[k[i]]); swap(k[s[i]],k[s[k[i]]]); } } if(vp.size()!=r+1){ vp.push_back({0,0}); } for(int i=0;i<N;i++){ s[i]=S[i]; } for(int i=0;i<N;i++){ k[s[i]]=i; } for(int i=0;i<=r;i++){ swap(s[X[i]],s[Y[i]]); swap(k[s[X[i]]],k[s[Y[i]]]); P[i]=k[vp[i].first]; Q[i]=k[vp[i].second]; } return r; }

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

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:59:14: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |  if(vp.size()!=r+1){
      |     ~~~~~~~~~^~~~~
#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...