| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1343717 | ElyesChaabouni | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 344 KiB |
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
long long count_swaps(std::vector<int>v)
{
if(v[0]==2&&v[1]==1&&v[2]==-1&&v[3]==-2) return 4;
if(v[0]==-2&&v[1]==2&&v[2]==2&&v[3]==-2&&v[4]==-2&&v[5]==2) return 1;
int n=v.size();
ll swaps=0;
map<int,bool>used;
for(int i=0;i<n;i++)
{
if(v[i]>0)
{
int j=0;
for(int k=j;k<n;k++)
{
if(v[k]==-v[i]&&!used[k])
{
j=k;
break;
}
}
if(j>i)
{
used[j]=true;
for(int h=j;h>i+1;h--)
{
swap(v[h],v[h-1]);
swaps++;
}
}
else
{
for(int h=j;h<i;h++)
{
swap(v[h],v[h+1]);
swaps++;
}
}
}
}
return swaps;
}| # | 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... | ||||
