This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define double long double
#define endl '\n'
#define sz(a) (int)a.size()
#define pb push_back
#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
long long count_swaps(vector<int> s) {
    ll n=sz(s);
    map<ll, queue<ll>> m;
    vector<bool> mark(n+5, 0);
    for(ll i=0;i<n;i++)
    {
        m[s[i]].push(i);
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(!mark[i])
        {
            if(s[i]<0)
            {
                ans+=(m[-s[i]].front()-i-1);
                mark[m[-s[i]].front()]=1;
                mark[i]=1;
                m[-s[i]].pop();
                m[s[i]].pop();
            }
            else
            {
                ans+=(m[-s[i]].front()-i);
                mark[m[-s[i]].front()]=1;
                mark[i]=1;
                m[-s[i]].pop();
                m[s[i]].pop();
            }
        }
    }
	return ans;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |