Submission #1259837

#TimeUsernameProblemLanguageResultExecution timeMemory
1259837nguynBubble Sort 2 (JOI18_bubblesort2)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "bubblesort2.h" using namespace std; #define ll long long #define F first #define S second #define pb push_back #define pii pair<int, int> const int N = 5e5 + 5; int n, q; vector<pii> vec; int st[4 * N]; int delta[4 * N]; void update(int id, int l, int r, int u, int v, int x) { if (u > r || v < l) return; if (u <= l && r <= v) { st[id] += x; delta[id] += x; return; } int mid = (l + r) / 2; update(id * 2, l, mid, u, v, x); update(id * 2 + 1, mid + 1, r, u, v, x); st[id] = delta[id] + max(st[id * 2], st[id * 2 + 1]); } vector<int> countScans(vector<int>& A, vector<int>& X, vector<int>& V) { for (int i = 0; i < A.size(); i++) { vec.pb({A[i], i}); } for (int i = 0; i < X.size(); i++) { vec.pb({V[i], X[i]}); } sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end()); for (int i = 0; i < A.size(); i++) { A[i] = upper_bound(vec.begin(), vec.end(), make_pair(A[i], i)) - vec.begin(); update(1, 1, vec.size(), A[i], A[i], i); update(1, 1, vec.size(), A[i] + 1, vec.size(), -1); } vector<int> res; for (int i = 0; i < X.size(); i++) { update(1, 1, vec.size(), A[X[i]], A[X[i]], - X[i]); update(1, 1, vec.size(), A[X[i]] + 1, vec.size(), 1); V[i] = upper_bound(vec.begin(), vec.end(), make_pair(V[i], X[i])) - vec.begin(); A[X[i]] = V[i]; update(1, 1, vec.size(), A[X[i]], A[X[i]], X[i]); update(1, 1, vec.size(), A[X[i]] + 1, vec.size(), -1); res.pb(st[1]); } return res; } // signed main() { // ios_base::sync_with_stdio(0); // cin.tie(0); // vector<int> A; // vector<int> X; // vector<int> V; // cin >> n >> q; // for (int i = 1; i <= n; i++) { // int x; // cin >> x; // A.pb(x); // } // for (int i = 1; i <= q; i++) { // int x; // cin >> x; // X.pb(x); // } // for (int i = 1; i <= q; i++) { // int x; // cin >> x; // V.pb(x); // } // vector<int> res = countScans(A, X, V); // for (int i : res) { // cout << i << ' '; // } // }

Compilation message (stderr)

/usr/bin/ld: /tmp/cc3fbB72.o: in function `main':
grader.cpp:(.text.startup+0x189): undefined reference to `countScans(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status