Submission #412411

#TimeUsernameProblemLanguageResultExecution timeMemory
412411nichkeBubble Sort 2 (JOI18_bubblesort2)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mxn = 1e6 + 100; vector<int> a, pos, val, ans; int timer; map<int, int> mp; set<int> ind[mxn]; int tree[4 * mxn], lazy[4 * mxn], lz[4 * mxn]; void push(int v, int l, int r) { if (r < l) return; if (lz[v] != 0) { tree[v] += lazy[v]; if (l != r) { lz[2 * v + 1] = 1; lz[2 * v + 2] = 1; lazy[2 * v + 1] += lazy[v]; lazy[2 * v + 2] += lazy[v]; } lazy[v] = 0; lz[v] = 0; } } void update(int v, int tl, int tr, int ql, int qr, int val) { push(v, tl, tr); if (tl > tr || tl > qr || tr < ql) return; if (tl >= ql && tr <= qr) { lz[v] = 1; lazy[v] += val; push(v, tl, tr); return; } int tm = (tl + tr) / 2; update(2 * v + 1, tl, tm, ql, qr, val); update(2 * v + 2, tm + 1, tr, ql, qr, val); tree[v] = max(tree[2 * v + 1], tree[2 * v + 2]); } void rem(int v, int x) { update(0, 0, timer - 1, x, timer - 1, 1); if (v == *ind[x].rbegin()) { auto it = ind[x].rbegin(); int val = -*it; it--; val += *it; update(0, 0, timer - 1, x, x, val); } ind[x].erase(v); } void add(int v, int x) { update(0, 0, timer - 1, x, timer - 1, -1); if (v > *ind[x].rbegin()) { update(0, 0, timer - 1, x, x, v - *ind[x].rbegin()); } ind[x].insert(v); a[v] = x; } void solve() { for (auto it : a) mp[it] = 1; for (auto it : val) mp[it] = 1; for (auto &it : mp) { it.second = timer++; } for (int i = 0; i < timer; i++) { ind[i].insert(-mxn); } for (int i = 0; i < a.size(); i++) { a[i] = mp[a[i]]; ind[a[i]].insert(i); update(0, 0, timer - 1, a[i], timer - 1, -1); } for (int i = 0; i < timer; i++) { update(0, 0, timer - 1, i, i, *ind[i].rbegin()); } for (int q = 0; q < pos.size(); q++) { rem(pos[q], a[pos[q]]); add(pos[q], mp[val[q]]); ans.push_back(tree[0] + 1); } } vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) { a = A; pos = X; val = V; solve(); return ans; }

Compilation message (stderr)

bubblesort2.cpp: In function 'void solve()':
bubblesort2.cpp:73:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |  for (int i = 0; i < a.size(); i++) {
      |                  ~~^~~~~~~~~~
bubblesort2.cpp:81:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |  for (int q = 0; q < pos.size(); q++) {
      |                  ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccynpDxT.o: in function `main':
grader.cpp:(.text.startup+0x19f): 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