# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
231122 | peijar | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
using ll = long long;
ll count_swaps(vector<int> shoes)
{
int nb_chaussures = SZ(shoes);
ll nb_swaps(0);
for (int i(1); i < nb_chaussures; ++i)
{
for (int j(0); j < i; ++j)
if (shoes[i] + shoes[j] == 0)
{
int cur = i;
while (cur > j+1)
{
swap(shoes[cur], shoes[cur-1]);
--cur;
++nb_swaps;
}
if (shoes[j] > 0)
{
++nb_swaps;
swap(shoes[j], shoes[j+1]);
}
shoes[j] = shoes[j+1] = 0;
break;
}
}
return nb_swaps;