Submission #1307490

#TimeUsernameProblemLanguageResultExecution timeMemory
1307490hectormedranoArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <cstdio> #include <cassert> #include <bits/stdc++.h> using namespace std; typedef long long ll; ll count_swaps(vector<int> s) { ll inv = 0; ll n = s.size(); n = n/2; vector<pair<ll, ll>> a; vector<queue<ll>> q(n+1); vector<ll> v; for(ll i=0;i<2*n;i++){ if(s[i]<0){ a.push_back({s[i], i}); a.push_back({-s[i], -1}); } else { q[s[i]].push(i); } v.push_back(i); } for(ll i=0;i<2*n;i++){ if(a[i].first > 0){ a[i].second = q[a[i].first].front(); q[a[i].first].pop(); } } for(ll i=0;i<2*n;i++){ ll j=2*n-1; while(v[j] != a[i].second){j--;} for(ll k=j;j>i;j--){ swap(v[j], v[j-1]); inv++; } } return inv; } int main() { int n; assert(1 == scanf("%d", &n)); vector<int> S(2 * n); for (int i = 0; i < 2 * n; i++) assert(1 == scanf("%d", &S[i])); fclose(stdin); long long result = count_swaps(S); printf("%lld\n", result); fclose(stdout); return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccq8QPKa.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc7FRBqJ.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status