Submission #1019467

#TimeUsernameProblemLanguageResultExecution timeMemory
1019467NicolaikrobArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms440 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll count_swaps(vector<int> T) { ll n = T.size(), ans = 0LL; vector<ll> S(n); for(int i = 0; i < n; i++) S[i] = T[i]; unordered_map<ll,vector<ll>> M; for(ll i = 0; i < n; i++) { if(M[S[i]].size()) { ans += (ll)i-M[S[i]].back(); if(S[i]>0LL) ans -= 1LL; M[S[i]].pop_back(); } else { M[-S[i]].push_back(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...