제출 #936858

#제출 시각아이디문제언어결과실행 시간메모리
9368584QT0RArranging Shoes (IOI19_shoes)C++17
10 / 100
71 ms134996 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long queue<pair<int,int>> pos[200004]; ll count_swaps(vector<int> S){ ll n=S.size(),open=0,odp=0; for (int i = 0; i<n; i++){ if (S[i]>0){ if (pos[S[i]+100000].empty()){ pos[S[i]].push({i,open}); open++; } else{ odp+=i-pos[S[i]+100000].front().first-1; open--; odp-=open-pos[S[i]+100000].front().second; pos[S[i]+100000].pop(); } } else{ if (pos[-S[i]].empty()){ pos[100000-S[i]].push({i,open}); open++; } else{ odp+=i-pos[-S[i]].front().first; open--; odp-=open-pos[-S[i]].front().second; pos[-S[i]].pop(); } } } return odp; }
#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...