Submission #1025418

#TimeUsernameProblemLanguageResultExecution timeMemory
1025418LuvidiArranging Shoes (IOI19_shoes)C++17
50 / 100
1095 ms14004 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); for(int j=0;j<=2*n;j++){ for(int &k:v[j]){ if(k<idx)k++; } } } 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...