Submission #766673

#TimeUsernameProblemLanguageResultExecution timeMemory
766673t6twotwoArranging Shoes (IOI19_shoes)C++17
10 / 100
1091 ms3124 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll count_swaps(vector<int> s) {
	int n = s.size() / 2;
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2) {
		int x = i;
		while (s[x] > 0) {
			x++;
		}
		for (int j = x; j > i; j--) {
			ans++;
			swap(s[j], s[j - 1]);
		}
		x = i + 1;
		while (s[x] != -s[i]) {
			x++;
		}
		for (int j = x; j > i + 1; j--) {
			ans++;
			swap(s[j], s[j - 1]);
		}
	}
	return ans;
}
#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...