Submission #808811

#TimeUsernameProblemLanguageResultExecution timeMemory
808811OrazBArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define ll long long int #define pii pair <int, int> #define pb push_back #define ff first #define ss second const int N = 2e5+5; int vis[N]; deque<int> lft[N], rgt[N]; ll count_swaps(vector<int> S){ int n = S.size(); S.insert(S.begin(), -1); for (int i = 1; i <= n; i++){ if (S[i] > 0) rgt[S[i]].pb(i); else lft[-S[i]].pb(i); } ll ans = 0; set<int> s; for (int i = 1; i <= n; i++){ while(s.size() and (*s.begin()) < i) s.erase(s.begin()); if (vis[i]) continue; int j; if (S[i] > 0) j = lft[S[i]].front(); else j = rgt[-S[i]].front(); lft[abs(S[i])].pop_front(); rgt[abs(S[i])].pop_front(); ans += (j-i-s.size()-(S[i] < 0)); s.insert(j); vis[j] = 1; } return ans; } int main () { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> S(2*n); for (int i = 0; i < 2*n; i++) cin >> S[i]; cout << count_swaps(S); }

Compilation message (stderr)

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