제출 #143759

#제출 시각아이디문제언어결과실행 시간메모리
143759dacin21Arranging Shoes (IOI19_shoes)C++17
10 / 100
1033 ms2040 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; using ll = int64_t; long long count_swaps(std::vector<int> v) { const int n = v.size()/2; ll ret = 0; for(int i=0;i<n;++i){ const int l = 2*i; int a = l; while(v[a] > 0) ++a; ret += a-l; rotate(v.begin()+l, v.begin()+a, v.begin()+a+1); assert(v[l] < 0); int b = l+1; while(v[b] != -v[l]) ++b; ret+=b-l-1; rotate(v.begin()+l+1, v.begin()+b, v.begin()+b+1); assert(v[l+1] == -v[l]); } return ret; }
#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...