제출 #1025413

#제출 시각아이디문제언어결과실행 시간메모리
1025413LuvidiArranging Shoes (IOI19_shoes)C++17
10 / 100
1076 ms8680 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int n=s.size()/2; vector<int> v[2*n+1]; for(int i=0;i<2*n;i++)v[s[i]+n].push_back(i); for(int i=0;i<=2*n;i++)reverse(v[i].begin(),v[i].end()); int ans=0; for(int i=0;i<2*n;i+=2){ int x; for(int j=0;j<=2*n;j++){ for(int k:v[j]){ if(k==i)x=j-n; } } int idx=v[-x+n].back(); v[-x+n].pop_back(); v[x+n].pop_back(); ans+=idx-1-i+(x>0); } return ans; }
#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...