Submission #1082741

#TimeUsernameProblemLanguageResultExecution timeMemory
1082741nickolasarapidisArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms348 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll count_swaps(vector<int> S){ int N = S.size(); ll ans = 0; map<int, ll> m; map<int, vector<int>> id; for(int i = 0; i < N; i++){ if(m[-S[i]] > 0){ if(S[i] < 0){ m[-S[i]]--; ans += i - id[-S[i]].back(); id[-S[i]].pop_back(); } else{ m[-S[i]]--; ans += i - id[-S[i]].back() - 1; id[-S[i]].pop_back(); } } else{ m[S[i]]++; id[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...