# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143841 | Bodo171 | Arranging Shoes (IOI19_shoes) | C++14 | 1083 ms | 16376 KiB |
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 <vector>
#include <iostream>
using namespace std;
const int nmax=100005;
vector<int> v[nmax];
int fin[nmax],po[nmax];
int nr,i,j;
long long count_swaps(vector<int> s) {
int n=s.size();
for(int i=0;i<n;i++)
{
if(s[i]<0)
{
v[-s[i]].push_back(nr);
fin[i]=2*nr;
nr++;
}
}
for(i=0;i<n;i++)
{
if(s[i]>0)
{
fin[i]=(2*v[s[i]][po[s[i]]]+1);
po[s[i]]++;
}
}
int ans=0;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
ans+=(fin[i]>fin[j]);
return ans;
}
Compilation message (stderr)
# | 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... |