| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 143422 | daniel920712 | Arranging Shoes (IOI19_shoes) | C++14 | 34 ms | 3592 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 <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <assert.h>
using namespace std;
int S1[1005];
int S2[1005];
int all[1005];
bool F(int a,int b)
{
return a<b;
}
long long count_swaps(std::vector<int> S)
{
long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),i,j,k,now=0,x,y;
long long t;
now=0;
for(i=0;i<N/2;i++)
{
x=y=0;
for(j=0;j<N;j++) S1[j]=S[j];
for(j=0;j<N;j++) S2[j]=S[j];
for(j=2*i;j<N;j++)
{
if(S1[j]<0)
{
t=0-S1[j];
for(k=j;k>2*i;k--)
{
x++;
swap(S1[k],S1[k-1]);
}
break;
}
}
for(j=2*i+1;j<N;j++)
{
if(S1[j]==t)
{
for(k=j;k>2*i+1;k--)
{
x++;
swap(S1[k],S1[k-1]);
}
break;
}
}
for(j=2*i;j<N;j++)
{
if(S2[j]>0)
{
t=0-S2[j];
break;
}
}
for(j=2*i;j<N;j++)
{
if(S2[j]==t)
{
for(k=j;k>2*i;k--)
{
y++;
swap(S2[k],S2[k-1]);
}
break;
}
}
for(j=2*i+1;j<N;j++)
{
if(S2[j]==0-t)
{
for(k=j;k>2*i+1;k--)
{
y++;
swap(S2[k],S2[k-1]);
}
break;
}
}
if(x<=y)
{
ans1+=x;
for(j=0;j<N;j++) S[j]=S1[j];
}
else
{
ans1+=y;
for(j=0;j<N;j++) S[j]=S2[j];
}
}
return ans1;
}
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... | ||||
