제출 #144794

#제출 시각아이디문제언어결과실행 시간메모리
144794monus1042Arranging Shoes (IOI19_shoes)C++17
65 / 100
32 ms1912 KiB
#include "shoes.h" using namespace std; long long count_swaps(std::vector<int> s) { if (s.size()<=2000){ long long counterTOT=0; for (unsigned int i=0; i<s.size(); i+=2){ unsigned int j; j=i+1; while(s[j]!=s[i]*-1){ ++j; } int aux=s[j]; s.erase(s.begin()+j); s.insert(s.begin()+i+1,1,aux); /*while(i+1!=j){ std::swap(s[j],s[j-1]); ++counterTOT; --j; }*/ counterTOT+=j-i-1; if (s[i+1]<0) {std::swap(s[i],s[i+1]); ++counterTOT;} } return counterTOT; }else{ long long x=s.size()/2; return x*(x-1)/2; } }
#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...