제출 #201726

#제출 시각아이디문제언어결과실행 시간메모리
201726a_playerArranging Shoes (IOI19_shoes)C++14
10 / 100
140 ms135056 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5+10; deque<int> d[2*MAXN]; int sh[MAXN]; bitset<MAXN> v; long long count_swaps(vector<int> s) { int N=s.size(); for(int i=0;i<N;i++)d[s[i]+MAXN].push_back(i); long long ans=0; int cont=0; for(int i=0;i<N;i++){ if(v[i])continue; cont+=sh[i]; v[i]=1; sh[i+1]++; assert(d[s[i]+MAXN].front()==i); d[s[i]+MAXN].pop_front(); int h=d[MAXN-s[i]].front(); v[h]=1; sh[h]--; d[MAXN-s[i]].pop_front(); if(s[i]>0&&(i+cont)%2==1)ans+=h-i-1; else if(s[i]<0&&(i+cont)%2==0)ans+=h-i-1; else if(s[i]>0&&(i+cont)%2==0)ans+=h-i; else ans+=h-i; } 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...