Submission #201264

#TimeUsernameProblemLanguageResultExecution timeMemory
201264khulegubArranging Shoes (IOI19_shoes)C++14
10 / 100
6 ms376 KiB
#include "shoes.h" #include <bits/stdc++.h> #define mp make_pair #define pb push_back #define xx first #define yy second using namespace std; typedef long long i64; i64 count_swaps(std::vector<int> s) { i64 ans = 0LL; int n = s.size(); map<int, vector<int> > maap; for (int i = n - 1; i >= 0; i--){ maap[s[i]].pb(i); } vector<bool> taken(n, 0); for (int i = 0; i < n; i++){ if (!taken[i]){ maap[s[i]].pop_back(); int tmp = maap[s[i] * -1].back(); maap[s[i] * -1].pop_back(); taken[tmp] = 1; if (s[i] < 0){ ans += tmp - i - 1; } else{ ans += tmp - 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...