제출 #1061892

#제출 시각아이디문제언어결과실행 시간메모리
1061892PetrixArranging Shoes (IOI19_shoes)C++17
100 / 100
334 ms148300 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+=((j)&(-(j)))) a[j]++; }else{ aux=np[-s[i]].front();np[-s[i]].pop_front(); rasp+=i; for(j=aux;j>0;j-=(j&(-j))) rasp-=a[j]; if(s[i]<0) rasp++; for(j=aux;j<=n;j+=(j&(-j))) 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...