Submission #1051587

#TimeUsernameProblemLanguageResultExecution timeMemory
1051587TobArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#inlcude "shoes.h"

#define F first
#define S second

using namespace std;

typedef long long ll;

const int N = 2e5 + 7;

int fen[N];
stack <int> st[N];

void add(int x, int val) {for (x++; x < N; x += x & -x) fen[x] += val;}
int get(int x) {int out = 0; for (x++; x; x -= x & -x) out += fen[x]; return out;}

ll count_swaps(vector <int> a) {
	int n = a.size();
	
	vector <int> pa(2*n, -1);
	for (int i = 0; i < n; i++) {
		int x = abs(a[i]);
		if (st[x].empty()) st[x].push(i);
		else {
			if ((a[i] > 0) == (a[st[x].top()] > 0)) st[x].push(i);
			else {
				pa[st[x].top()] = i;
				st[x].pop();
			}
		}
	}
	
	ll res = 0;
	for (int i = 0; i < 2*n; i++) {
		if (pa[i] == -1) continue;
		res += pa[i]-i-(a[i] < 0) - get(pa[i])+get(i);
		add(pa[i], 1);
	}
	
	return res;
}

Compilation message (stderr)

shoes.cpp:3:2: error: invalid preprocessing directive #inlcude; did you mean #include?
    3 | #inlcude "shoes.h"
      |  ^~~~~~~
      |  include