제출 #314791

#제출 시각아이디문제언어결과실행 시간메모리
314791kylych03정렬하기 (IOI15_sorting)C++14
0 / 100
2 ms640 KiB
#include"sorting.h" #include<bits/stdc++.h> //#include"grader.cpp" using namespace std; int n,s[800005],x[800005],y[800005],tmp[800005],pos[800005]; vector<pair<int,int>>res; bool check(int m){ int i; for(i=0;i<n;i++)tmp[i]=s[i]; for(i=0;i<m;i++)swap(tmp[x[i]],tmp[y[i]]); for(i=0;i<n;i++)pos[tmp[i]]=i; vector<pair<int,int>>sw; res.clear(); for(i=0;i<n;i++){ if(pos[i]==i)continue; sw.push_back({tmp[i],tmp[pos[i]]}); swap(tmp[pos[i]],tmp[i]); swap(pos[tmp[pos[i]]],pos[tmp[i]]); } if(sw.size()>m)return 0; for(i=0;i<n;i++)tmp[i]=s[i],pos[tmp[i]]=i; for(i=0;i<sw.size();i++){ swap(tmp[x[i]],tmp[y[i]]); swap(pos[tmp[x[i]]],pos[tmp[y[i]]]); res.push_back({pos[sw[i].first],pos[sw[i].second]}); swap(tmp[pos[sw[i].first]],tmp[pos[sw[i].second]]); swap(pos[tmp[pos[sw[i].first]]],pos[tmp[pos[sw[i].second]]]); } for(;i<m;i++)res.push_back({0,0}); return 1; } int findSwapPairs(int N,int S[],int m,int X[],int Y[],int P[],int Q[]){ n=N; int i; for(i=0;i<n;i++)s[i]=S[i]; for(i=0;i<m;i++)x[i]=X[i]; for(i=0;i<m;i++)y[i]=Y[i]; check(m); for(i=0;i<m;i++)P[i]=res[i].first,Q[i]=res[i].second; return m; }

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

sorting.cpp: In function 'bool check(int)':
sorting.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(sw.size()>m)return 0;
      |        ~~~~~~~~~^~
sorting.cpp:22:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(i=0;i<sw.size();i++){
      |             ~^~~~~~~~~~
#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...