Submission #1235190

#TimeUsernameProblemLanguageResultExecution timeMemory
1235190rhm_ganArranging Shoes (IOI19_shoes)C++20
50 / 100
1095 ms1864 KiB
#include "shoes.h"
#include <bits/stdc++.h>

using namespace std;

long long count_swaps(vector<int> a) {
	int n = a.size();
	long long res = 0;
	for (int i = 0; i < n; i += 2) {
		int id = 0;
		for (int j = i + 1; j < n; j++) {
			if (-a[j] == a[i]) {
				id = j;
				break;
			}
		}
		res += id - i - 1;
		for (int j = id - 1; j > i; j--) {
			swap(a[j], a[j + 1]);
		}
		if (a[i] > 0) {
			res++;
			swap(a[i], a[i + 1]);
		}
	}

	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...