| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1311413 | 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){
int ans = 0;
map<int,int> mp;
for(int i = 0; i < S.size(); i++){
mp[S[i]] = i;
}
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;
}
