제출 #867430

#제출 시각아이디문제언어결과실행 시간메모리
867430cheat_when_I_was_youngArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms348 KiB
#include "shoes.h" #include "bits/stdc++.h" using namespace std; long long count_swaps(vector<int> s) { int n = (int)s.size() / 2; vector<vector<int>> l(n+1, vector<int>()); vector<queue<int>> r(n+1, queue<int>()); long long ans = 0; int cnt = 0; for (int i = 0; i < (int)s.size(); ++i) { if (s[i] < 0) { s[i] = -s[i]; if (r[s[i]].size()) { ans += i - r[s[i]].front() - cnt; ++cnt; r[s[i]].pop(); } else l[s[i]].push_back(i); } else { if (l[s[i]].size()) { ans += i - l[s[i]].back() - 1; l[s[i]].pop_back(); } else r[s[i]].push(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...