Submission #1123733

#TimeUsernameProblemLanguageResultExecution timeMemory
1123733math_rabbit_1028Nile (IOI24_nile)C++20
Compilation error
0 ms0 KiB
#include "nile.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pll; int N; struct minseg { ll tree[404040]; void init(int v, int st, int ed) { if (st == ed) { tree[v] = 1e18; return; } int mid = (st+ed)/2; init(2*v, st, mid); init(2*v+1, mid+1, ed); tree[v] = min(tree[2*v], tree[2*v+1]); } void update(int v, int st, int ed, int idx, ll val) { if (st > idx || ed < idx) return; if (st == idx && ed == idx) { tree[v] = min(tree[v], val); return; } int mid = (st+ed)/2; update(2*v, st, mid, idx, val); update(2*v+1, mid+1, ed, idx, val); tree[v] = min(tree[2*v], tree[2*v+1]); } ll get(int v, int st, int ed, int lt, int rt) { if (lt > ed || rt < st) return 1e18; if (lt <= st && ed <= rt) return tree[v]; int mid = (st+ed)/2; return min(get(2*v, st, mid, lt, rt), get(2*v+1, mid+1, ed, lt, rt)); } } o1, o2, e1, e2; vector<pll> C; ll block(int st, int ed) { // [st, ed] if ((ed-st)%2 == 1) return 0; if (st%2) return min(o1.get(1, 0, N-1, st, ed), e2.get(1, 0, N-1, st, ed)); else return min(e1.get(1, 0, N-1, st, ed), o2.get(1, 0, N-1, st, ed)); } vector<ll> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) { int Q = (int)E.size(); N = (int)W.size(); ll sum = 0; for (int i = 0; i < N; i++) sum += B[i]; vector<ll> R(Q, sum); for (int i = 0; i < N; i++) C.push_back({W[i], A[i]-B[i]}); sort(C.begin(), C.end()); o1.init(1, 0, N-1); e1.init(1, 0, N-1); for (int i = 0; i < N; i++) { if (i%2) o1.update(1, 0, N-1, i, C[i].second); else e1.update(1, 0, N-1, i, C[i].second); } o2.init(1, 0, N-1); e2.init(1, 0, N-1); priority_queue<pll, vector<pll>, greater<pll>> two, one; for (int i = 1; i < N-1; i++) { two.push({C[i+1].first - C[i-1].first, i}); } for (int i = 1; i < N; i++) { one.push({C[i].first - C[i-1].first, i}); } vector<ll> qry; map<ll, ll> ans; for (int i = 0; i < Q; i++) qry.push_back(E[i]); sort(qry.begin(), qry.end()); qry.erase(unique(qry.begin(), qry.end()), qry.end()); map<pll, ll> blocks; sum = 0; for (int i = 0; i < N; i++) { blocks[{i, i}] = C[i].second; sum += C[i].second; } for (ll D : qry) { while (!two.empty()) { if (two.top().first > D) break; int i = two.top().second; if (i%2) o2.update(1, 0, N-1, i, C[i].second); else e2.update(1, 0, N-1, i, C[i].second); auto iter = blocks.upper_bound({i, 0}); iter--; sum -= iter->second; iter->second = block(iter->first.first, iter->first.second); sum += iter->second; two.pop(); } while (!one.empty()) { if (one.top().first > D) break; int i = one.top().second; auto now = blocks.lower_bound({i, 0}); auto prev = now; prev--; sum -= now->second; sum -= prev->second; pll temp = {prev->first.first, now->first.second}; blocks[temp] = block(prev->first.first, now->first.second); blocks.erase(prev); blocks.erase(now); sum += blocks[temp]; one.pop(); } ans[D] = R[0] + sum; } for (int t = 0; t < Q; t++) { R[t] = ans[E[t]]; } return R; }

Compilation message (stderr)

nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:64:38: error: 'greater' was not declared in this scope
   64 |     priority_queue<pll, vector<pll>, greater<pll>> two, one;
      |                                      ^~~~~~~
nile.cpp:64:38: note: suggested alternatives:
In file included from /usr/include/c++/11/bits/iterator_concepts.h:37,
                 from /usr/include/c++/11/bits/stl_iterator_base_types.h:71,
                 from /usr/include/c++/11/bits/stl_algobase.h:65,
                 from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/bits/ranges_cmp.h:140:10: note:   'std::ranges::greater'
  140 |   struct greater
      |          ^~~~~~~
In file included from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/compare:53:57: note:   'std::__cmp_cat::_Ord::greater'
   53 |     enum class _Ord : type { equivalent = 0, less = -1, greater = 1 };
      |                                                         ^~~~~~~
nile.cpp:64:5: error: 'priority_queue' was not declared in this scope
   64 |     priority_queue<pll, vector<pll>, greater<pll>> two, one;
      |     ^~~~~~~~~~~~~~
nile.cpp:2:1: note: 'std::priority_queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    1 | #include "nile.h"
  +++ |+#include <queue>
    2 | using namespace std;
nile.cpp:64:23: error: expected primary-expression before ',' token
   64 |     priority_queue<pll, vector<pll>, greater<pll>> two, one;
      |                       ^
nile.cpp:64:36: error: expected primary-expression before ',' token
   64 |     priority_queue<pll, vector<pll>, greater<pll>> two, one;
      |                                    ^
nile.cpp:64:49: error: expected primary-expression before '>' token
   64 |     priority_queue<pll, vector<pll>, greater<pll>> two, one;
      |                                                 ^~
nile.cpp:64:52: error: 'two' was not declared in this scope
   64 |     priority_queue<pll, vector<pll>, greater<pll>> two, one;
      |                                                    ^~~
nile.cpp:64:57: error: 'one' was not declared in this scope
   64 |     priority_queue<pll, vector<pll>, greater<pll>> two, one;
      |                                                         ^~~
nile.cpp:72:5: error: 'map' was not declared in this scope
   72 |     map<ll, ll> ans;
      |     ^~~
nile.cpp:2:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
    1 | #include "nile.h"
  +++ |+#include <map>
    2 | using namespace std;
nile.cpp:72:11: error: expected primary-expression before ',' token
   72 |     map<ll, ll> ans;
      |           ^
nile.cpp:72:15: error: expected primary-expression before '>' token
   72 |     map<ll, ll> ans;
      |               ^
nile.cpp:72:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   72 |     map<ll, ll> ans;
      |                 ^~~
      |                 abs
nile.cpp:77:12: error: expected primary-expression before ',' token
   77 |     map<pll, ll> blocks;
      |            ^
nile.cpp:77:16: error: expected primary-expression before '>' token
   77 |     map<pll, ll> blocks;
      |                ^
nile.cpp:77:18: error: 'blocks' was not declared in this scope; did you mean 'block'?
   77 |     map<pll, ll> blocks;
      |                  ^~~~~~
      |                  block
nile.cpp:103:61: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'pll' {aka 'std::pair<long long int, long long int>'}
  103 |             pll temp = {prev->first.first, now->first.second};
      |                                                             ^
      |                                                             |
      |                                                             <brace-enclosed initializer list>