Submission #1061888

#TimeUsernameProblemLanguageResultExecution timeMemory
1061888PetrixArranging Shoes (IOI19_shoes)C++17
10 / 100
1071 ms33876 KiB
#include <iostream> #include <vector> #include <map> #include <deque> #include "shoes.h" using namespace std; long long count_swaps(vector<int> s){ int n=s.size(); map<int,deque<int>> np; vector<int> a(n+1); long long i,j,aux,rasp=0; for(i=0;i<n;i++){ if(np[-s[i]].size()==0){ np[s[i]].push_back(i+1); for (j=i+1;j<=n;j+=(i+1)&(-(i+1))) a[j]++; }else{ aux=np[-s[i]].front();np[-s[i]].pop_front(); rasp+=i; for(j=aux;j;j-=aux&(-aux)) rasp-=a[j]; if(s[i]<0) rasp++; for(j=aux;j<=n;j+=aux&(-aux)) a[j]++; } } return rasp; }
#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...