Submission #294969

#TimeUsernameProblemLanguageResultExecution timeMemory
294969ASDF123Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> #define ll long long #define szof(s) (int)s.size() using namespace std; const int N = (int)2e5 + 5; int tree[N * 4], lz[N * 4]; unordered_map <int, int> pos; bool used[N]; void push(int v, int tl, int tr) { if (!lz[v]) { return; } if (tl != tr) { lz[v + v + 1] += lz[v]; lz[v + v + 2] += lz[v]; } else { tree[v] += lz[v]; } lz[v] = 0; } int get(int pos, int v = 0, int tl = 0, int tr = N) { push(v, tl, tr); if (tl == tr) { return tree[v]; } int mid = (tl + tr) >> 1; if (pos <= mid) { return get(pos, v + v + 1, tl, mid); } else { return get(pos, v + v + 2, mid + 1, tr); } } void upd(int l, int r, int val, int v = 0, int tl = 0, int tr = N) { push(v, tl, tr); if (l <= tl && tr <= r) { lz[v] += val; push(v, tl, tr); return; } if (l > tr || tl > r) { return; } int mid = (tl + tr) >> 1; upd(l, r, val, v + v + 1, tl, mid); upd(l, r, val, v + v + 2, mid + 1, tr); } ll count_swaps(vector<int> s) { ll ans = 0; int n = szof(s) / 2; for (int i = 0; i < n * 2; i++) { pos[s[i]] = i; } for (int i = 0; i < n * 2; i++) { if (!used[i]) { used[pos[s[i]]] = used[pos[-s[i]]] = 1; int l = pos[s[i]] + get(pos[s[i]]); int r = pos[-s[i]] + get(pos[-s[i]]); //cout << "! " << r - (l + 1) << endl; ans += r - (l + 1); if (s[i] > 0) { ans++; } upd(pos[s[i]] + 1, pos[-s[i]] - 1, 1); } } return ans; } //signed main() { //int n; //cin >> n; //vector <int> s(n); //for (int &el : s) { //cin >> el; //} //cout << count_swaps(s); }

Compilation message (stderr)

shoes.cpp:85:1: error: expected declaration before '}' token
   85 | }
      | ^