제출 #832330

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
8323302023-08-21 09:08:16ttamxSorting (IOI15_sorting)C++14
100 / 100
218 ms15056 KiB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> s,x,y;
vector<pair<int,int>> ans;
bool chk(int val,bool gen=false){
vector<int> id(n),pos(n),pos2(n),tar(n);
iota(id.begin(),id.end(),0);
iota(tar.begin(),tar.end(),0);
iota(pos2.begin(),pos2.end(),0);
for(int i=0;i<val;i++)swap(tar[x[i]],tar[y[i]]);
for(int i=0;i<n;i++)pos[s[i]]=i;
auto seq=s;
auto doswap=[&](int u,int v){
swap(seq[u],seq[v]);
swap(pos[seq[u]],pos[seq[v]]);
swap(id[u],id[v]);
swap(pos2[id[u]],pos2[id[v]]);
};
int cnt=0;
for(int i=0;i<n;i++){
if(id[pos[i]]!=tar[i]){
doswap(x[cnt],y[cnt]);
int u=pos[i],v=pos2[tar[i]];
if(gen)ans.emplace_back(u,v);
swap(seq[u],seq[v]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:53:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |  while(ans.size()<l)ans.emplace_back(0,0);
      |        ~~~~~~~~~~^~
#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...