답안 #627676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
627676 2022-08-12T18:24:27 Z 4123xr4323 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define all(a) a.begin(),a.end()
using namespace std;
using pii = pair <int, int>;
constexpr int maxn = 1e5 + 10;
constexpr long long inf = 1e17 + 10;

vector <pii> tree (maxn << 2, mp (0, -inf));
vector <pii> A (maxn << 2, mp (-inf, -inf));

inline void push (int v, int t_l, int t_r) {
    tree[v].first = max (tree[v].first, A[v].first);
    tree[v].second = max (tree[v].second, A[v].second);
    if (t_l != t_r) {
        A[v << 1].first = max (A[v << 1].first, A[v].first);
        A[v << 1].second = max (A[v << 1].second, A[v].second);
        A[v << 1 | 1].first = max (A[v << 1 | 1].first, A[v].first);
        A[v << 1 | 1].second = max (A[v << 1 | 1].second, A[v].second);
    }
    A[v] = mp (-inf, -inf);
}

inline void update (int l, int r, pii x, int v, int t_l, int t_r) {
    push (v, t_l, t_r);
    if (l > t_r || t_l > r) return;
    if (l <= t_l && t_r <= r) {
        A[v] = x;
        push (v, t_l, t_r);
        return;
    }
    int t_m = t_l + t_r >> 1;
    update (l, r, x, v << 1, t_l, t_m);
    update (l, r, x, v << 1 | 1, t_m + 1, t_r);
    tree[v].first = max (tree[v << 1].first, tree[v << 1 | 1].first);
    tree[v].second = max (tree[v << 1].second, tree[v << 1 | 1].second);
}

inline pii get (int i, int v, int t_l, int t_r) {
    if (i > t_r || t_l > i) return mp (-inf, -inf);
    push (v, t_l, t_r);
    if (t_l == t_r) return tree[v];
    int t_m = t_l + t_r >> 1;
    return max (get (i, v << 1, t_l, t_m), get (i, v << 1 | 1, t_m + 1, t_r));
}

vector <pii> pos [maxn];
int last = 0;

int max_weights (int N, int M, vector <int> X, vector <int> Y, vector <int> W) {
    /*for (int i = 0; i < M; ++i) {
        pos[X[i] + 1].push_back (mp (Y[i] + 1, W[i]));
    }
    int n = N;
    for (int i = 1; i <= n; ++i) sort (all (pos[i]));
    for (int i = 1; i <= n; ++i) {
        for (pii j : pos[i]) {
            int am = get (j.first, 1, 0, n).first + j.second;
            update (j.first + 1, n, mp (am, -inf), 1, 0, n);
        }
        for (int _j = (int) pos[i].size () - 1; _j >= 0; --_j) {
            pii j = pos[i][_j];
            int am = get (j.first, 1, 0, n).second + j.second;
            update (0, j.first - 1, mp (-inf, am), 1, 0, n);
        }
        int to = get (n, 1, 0, n).first, from = get (0, 1, 0, n).second;
        update (0, n, mp (from, last), 1, 0, n);
        last = max (to, from);
    }
    return get (0, 1, 0, n).second;*/
    int res = 0;
    for (int i = 0; i < M; ++i) res += W[i];
    return res;
}

Compilation message

fish.cpp: In function 'void update(long long int, long long int, pii, long long int, long long int, long long int)':
fish.cpp:33:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |     int t_m = t_l + t_r >> 1;
      |               ~~~~^~~~~
fish.cpp: In function 'pii get(long long int, long long int, long long int, long long int)':
fish.cpp:44:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   44 |     int t_m = t_l + t_r >> 1;
      |               ~~~~^~~~~
/usr/bin/ld: /tmp/cc6qu6zo.o: in function `main':
grader.cpp:(.text.startup+0x25e): undefined reference to `max_weights(int, int, 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