Submission #928967

#TimeUsernameProblemLanguageResultExecution timeMemory
928967AtabayRajabliArranging Shoes (IOI19_shoes)C++17
0 / 100
1 ms348 KiB
#include "shoes.h" #include <bits/stdc++.h> long long count_swaps(std::vector<int> s) { int N = s.size() / 2; std::map<int, std::set<int>> mp; for(int i = 0; i < N * 2; i++) { mp[s[i]].insert(i); } long long ans = 0; for(int i = 0; i < N * 2; i++) { if(mp[s[i]].empty())continue; auto it = mp[-s[i]].upper_bound(i); int ind = *it; if(s[i] < 0)ans += ind - i - 1; else ans += ind - i + 1; mp[-s[i]].erase(it); } 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...