Submission #881376

#TimeUsernameProblemLanguageResultExecution timeMemory
881376theghostkingArranging 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) { long long sz = s.size(); vector<bool> vis(sz); map<long long,queue<long long>> mp; for (long long i = 0; i<sz; i++){ mp[s[i]].push(i); } long long ans = 0; for (long long i = 0; i<sz; i++){ if (vis[i]) continue; mp[s[i]].pop(); long long rev = -s[i]; long long v = mp[rev].front(); vis[v] = true; mp[rev].pop(); ans += v-i-(s[i]<0); } 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...