| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1292555 | lukaye_19 | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> shoes) {
long long Answer = 0;
vector<int> S = shoes;
while (S.size() != 0)
{
int FirstShoe = S[0];
int FirstShoeSize = abs(A);
int ShoeIndex = -1;
for (int i = 1; i < (int)S.size(); i++)
{
if (abs(S[i]) == FirstShoe)
{
Answer = i;
break;
}
}
if (FirstShoe > 0)
{
Answer += (ShoeIndex - 1);
while (ShoeIndex > 1)
{
swap(S[ShoeIndex], S[ShoeIndex - 1]);
ShoeIndex--;
}
}
else
{
Answer += ShoeIndex;
while (ShoeIndex > 0)
{
swap(S[ShoeIndex], S[ShoeIndex - 1]);
ShoeIndex--;
}
}
S.erase(S.begin());
S.erase(S.begin());
}
return Answer;
}
