Submission #1327830

#TimeUsernameProblemLanguageResultExecution timeMemory
1327830MansurtArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll int64_t
using namespace std;

const ll N = 1e5 + 5;
vector<ll> point(N, 1);

int main() {
	ll n; cin >> n;
	vector<ll> a(n+1);
	vector<ll> neg[N], pos[N];
	vector<bool> was(n+1, 1);
	for (int i = 1; i <= n; i++) {
	    cin >> a[i];
	    if (a[i] > 0) pos[a[i]].push_back(i);
	    else neg[(-1)*a[i]].push_back(i);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
	    if (!was[i]) continue;

        if (a[i] > 0) {

        while (point[a[i]] < pos[a[i]].size() && !was[pos[a[i]][point[a[i]]]]) point[a[i]]++;

            ll j = pos[a[i]][point[a[i]]];
            ans += abs(i - j);

        was[i] = false;
        was[j] = false;

        point[a[i]]++;
    }
        else {

        ll sz = -a[i];

        while (point[sz] < neg[sz].size() && !was[neg[sz][point[sz]]]) point[sz]++;

        ll j = neg[sz][point[sz]];
        ans += abs(i - j) - 1;

        was[i] = false;
        was[j] = false;

        point[sz]++;
        }
	}
	cout << ans;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc53UUfM.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc2JJQGb.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc53UUfM.o: in function `main':
grader.cpp:(.text.startup+0x26b): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status