이 제출은 이전 버전의 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)
{
cout << i << endl;
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]);
cerr << "Swapping " << shoes[cur-1] << ' ' << shoes[cur] << endl;
--cur;
++nb_swaps;
}
if (shoes[j] > 0)
{
++nb_swaps;
cerr << "Last Swapping " << shoes[j] << ' ' << shoes[j+1] << endl;
swap(shoes[j], shoes[j+1]);
}
shoes[j] = shoes[j+1] = 0;
break;
}
}
return nb_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... |