# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211063 | lyh | Arranging Shoes (IOI19_shoes) | C++14 | 0 ms | 0 KiB |
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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> S) {
// long long count_swaps() {
long long sum= 0;
for(int i= 0; i < 2 * n; i+= 2) {
int k;
for(k= i; k < 2 * n; k++) {
if(S[k] > 0) break;
}
for(int j= k; j > i; j--) {
swap(S[j], S[j - 1]);
sum++;
}
for(k= i + 1; k < 2 * n; k++) {
if(S[k] == -S[i]) {
break;
}
}
for(int j= k; j > i + 1; j--) {
swap(S[j], S[j - 1]);
sum++;
}
}
return sum;
}