Submission #1082094

#TimeUsernameProblemLanguageResultExecution timeMemory
1082094logangdArranging Shoes (IOI19_shoes)C++14
10 / 100
3 ms4956 KiB
#include "shoes.h" using namespace std; vector<int>p[200001]; long long count_swaps(vector<int>s){ int n=s.size(); for(int i=n-1;0<=i;i--)p[s[i]+n].push_back(i); long long r=0; for(int i=0;i<n;i++){ if(p[s[i]+n].back()!=i)continue; p[s[i]+n].pop_back(); if(s[i]<0)r+=p[n-s[i]].back()-i-1,p[n-s[i]].pop_back(); else r+=p[n-s[i]].back()-i,p[n-s[i]].pop_back(); } return r; }
#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...