Submission #988071

# Submission time Handle Problem Language Result Execution time Memory
988071 2024-05-24T03:02:42 Z long Trading (IZhO13_trading) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e5 + 10;
 
int seg[N * 4], laz[N * 4];
 
void push(int id) {
    int &t = laz[id];
    laz[id * 2] += t;
    laz[id * 2 + 1] += t;
    seg[id * 2] += t;
    seg[id * 2 + 1] += t;
    t = 0;
}
 
void upd(int id, int l, int r, int u, int v, int c) {
    if (l > v || r < u)
        return;
 
    if (l >= u && r <= v) {
        laz[id] += c;
        seg[id] += c;
        return;
    }
 
    push(id);
    int m = (l + r) / 2;
    upd(id * 2, l, m, u, v, c);
    upd(id * 2 + 1, m + 1, r, u, v, c);
    seg[id] = max(seg[id * 2], seg[id * 2 + 1]);
}
 
void run(int id, int l, int r, int p, int v) {
    if (l > p || r < p)
        return;
 
    if (l == r) {
        seg[id] = v;
        laz[id] = 0;
        return;
    } 
 
    push(id);
    int m = (l + r) / 2;
    run(id * 2, l, m, p, v);
    run(id * 2 + 1, m + 1, r, p, v);
    seg[id] = max(seg[id * 2], seg[id * 2 + 1]);
}
 
vector <int> event[N];
int l[N], r[N], v[N];
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    seg[1] = laz[1] = -1e8;
    int n, m;
    cin >> n >> m;
 
    for (int i = 1; i <= m; i++) {
        cin >> l[i] >> r[i] >> v[i];
        event[l[i]].pb(i);
        event[r[i] + 1].pb(-i);
    }
 
    for (int i = 1; i <= n; i++) {
        upd(1, 1, m, 1, m, 1);
        for (auto x : event[i]) {
            if (x > 0) {
                run(1, 1, m, x, v[x]);
            } else {
                run(1, 1, m, -x, -1e8);
            }
        }
 
        cout << max(0, seg[1]) << " ";
    }
 
    return 0;
} 

Compilation message

cc1plus: error: '::main' must return 'int'
trading.cpp: In function 'int main()':
trading.cpp:65:21: error: 'class std::vector<long long int>' has no member named 'pb'
   65 |         event[l[i]].pb(i);
      |                     ^~
trading.cpp:66:25: error: 'class std::vector<long long int>' has no member named 'pb'
   66 |         event[r[i] + 1].pb(-i);
      |                         ^~
trading.cpp:79:30: error: no matching function for call to 'max(int, long long int&)'
   79 |         cout << max(0, seg[1]) << " ";
      |                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from trading.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
trading.cpp:79:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   79 |         cout << max(0, seg[1]) << " ";
      |                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from trading.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
trading.cpp:79:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   79 |         cout << max(0, seg[1]) << " ";
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from trading.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
trading.cpp:79:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   79 |         cout << max(0, seg[1]) << " ";
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from trading.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
trading.cpp:79:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   79 |         cout << max(0, seg[1]) << " ";
      |                              ^