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<bits/stdc++.h>
#include "shoes.h"
//#include "grader.cpp"
using namespace std;
const int maxn = 1e5+3;
long long i,j,ans,p;
vector <int> pos[maxn*2];
long long count_swaps(vector<int> s)
{
ans = 0;
j = 1;
for(auto i:s)
{
if(pos[-i+maxn].empty())
pos[i+maxn].push_back(j);
else
{
p = pos[-i+maxn].back();
pos[-i+maxn].pop_back();
ans+=j-p-1;
if(i<0)
ans++;
}
j++;
}
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... |