| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1311415 | nikoloz-ch | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "shoes.h"
using namespace std;
long long count_swaps(vector<int> &S){
long long ans = 0;
map<int,int> mp;
for(int i = 0; i < S.size(); i++){
mp[S[i]] = i;
} set<int> st;
for(int i = 0; i < S.size(); i++){
if(S[i] < 0) continue;
if(st.find(S[i]) == st.end()){
ans += abs(mp[S[i]]-mp[-S[i]]);
st.insert(-S[i]); st.insert(S[i]);
}
}
return ans;
}
