Submission #892891

# Submission time Handle Problem Language Result Execution time Memory
892891 2023-12-26T06:34:58 Z Trisanu_Das Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<pair<int, int> > fishes[100005];
 
struct SegmentTree{
    ll tree[1 << 18];
    void init() {
        memset(seg, 0xcf, sizeof(tree));
    }
    void up(int idx, int s, int e, int l, int r, ll val) {
        if (e < l || r < s) return;
        if (l <= s && e <= r) {
            tree[idx] = max(tree[idx], val);
            return;
        }
        int mid = (s + e) / 2;
        update(2 * idx, s, mid, l, r, val);
        update(2 * idx + 1, mid + 1, e, l, r, val);
    }
    ll qry(int idx, int s, int e, int x) {
        if (s == e) return tree[i];
        int mid = (s + e) / 2;
        if (x <= mid) return max(tree[idx], qry(2 * idx, s, mid, x));
        return max(tree[idx], qry(2 * i + 1, mid + 1, e, x));
    }
} st_up, st_down;
 
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    for (int i = 0; i < M; i++) fishes[X[i] + 1].push_back(Y[i] + 1, W[i]);
    ll till_now = 0;
    st_down.init();
    for (int i = 1; i <= n; i++) {
        sort(fishes[i].begin(), fishes[i].end());
        for (auto [j, w] : fishes[i])  st_up.upd(1, 0, N + 1, j + 1, N + 1, st_up.qry(1, 0, N + 1, j) + val);
        reverse(fishes[i].begin(), fishes[i].end());
        for (auto [j, w] : fishes[i]) st_down.update(1, 0, N + 1, 0, j - 1, st_down.qry(1, 0, N + 1, j) + val);
        ll u_res = st_up.qry(1, 0, N + 1, N + 1), d_res = st_down.qry(1, 0, N + 1, 0);
        st_up.update(1, 0, N + 1, 0, N + 1, d_res);
        st_down.update(1, 0, N + 1, 0, N + 1, till_now);
        till_now = max(u_res, d_res);
    }
    return st_down.qry(1, 0, N + 1, 0);
}

Compilation message

fish.cpp: In member function 'void SegmentTree::init()':
fish.cpp:11:16: error: 'seg' was not declared in this scope
   11 |         memset(seg, 0xcf, sizeof(tree));
      |                ^~~
fish.cpp: In member function 'void SegmentTree::up(int, int, int, int, int, ll)':
fish.cpp:20:9: error: 'update' was not declared in this scope
   20 |         update(2 * idx, s, mid, l, r, val);
      |         ^~~~~~
fish.cpp: In member function 'll SegmentTree::qry(int, int, int, int)':
fish.cpp:24:33: error: 'i' was not declared in this scope
   24 |         if (s == e) return tree[i];
      |                                 ^
fish.cpp:27:39: error: 'i' was not declared in this scope
   27 |         return max(tree[idx], qry(2 * i + 1, mid + 1, e, x));
      |                                       ^
fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:32:74: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   32 |     for (int i = 0; i < M; i++) fishes[X[i] + 1].push_back(Y[i] + 1, W[i]);
      |                                                                          ^
In file included from /usr/include/c++/10/vector:67,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 2 provided
fish.cpp:35:26: error: 'n' was not declared in this scope
   35 |     for (int i = 1; i <= n; i++) {
      |                          ^
fish.cpp:37:46: error: 'struct SegmentTree' has no member named 'upd'; did you mean 'up'?
   37 |         for (auto [j, w] : fishes[i])  st_up.upd(1, 0, N + 1, j + 1, N + 1, st_up.qry(1, 0, N + 1, j) + val);
      |                                              ^~~
      |                                              up
fish.cpp:37:105: error: 'val' was not declared in this scope
   37 |         for (auto [j, w] : fishes[i])  st_up.upd(1, 0, N + 1, j + 1, N + 1, st_up.qry(1, 0, N + 1, j) + val);
      |                                                                                                         ^~~
fish.cpp:39:47: error: 'struct SegmentTree' has no member named 'update'
   39 |         for (auto [j, w] : fishes[i]) st_down.update(1, 0, N + 1, 0, j - 1, st_down.qry(1, 0, N + 1, j) + val);
      |                                               ^~~~~~
fish.cpp:39:107: error: 'val' was not declared in this scope
   39 |         for (auto [j, w] : fishes[i]) st_down.update(1, 0, N + 1, 0, j - 1, st_down.qry(1, 0, N + 1, j) + val);
      |                                                                                                           ^~~
fish.cpp:41:15: error: 'struct SegmentTree' has no member named 'update'
   41 |         st_up.update(1, 0, N + 1, 0, N + 1, d_res);
      |               ^~~~~~
fish.cpp:42:17: error: 'struct SegmentTree' has no member named 'update'
   42 |         st_down.update(1, 0, N + 1, 0, N + 1, till_now);
      |                 ^~~~~~