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 <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... |