Submission #1209549

#TimeUsernameProblemLanguageResultExecution timeMemory
1209549anfiNile (IOI24_nile)C++20
Compilation error
0 ms0 KiB
#include "nile.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
using int64 = long long;
#define pi pair<int64, int64>
#define artefak pair<pi, pi>
const int64 inf = -(1 << 40);
const int64 mxn = (1 << 18);
int64 parent[4*mxn],sz[4*mxn],val[mxn*4][2],mx[mxn*4];

int64 find(int n){
    return parent[n] == n ? n : parent[n] = find(parent[n]);
}

int64 hitung(int n){
    if(sz[n]%2 == 0) return 0;
    return max(val[n][n&1], mx[n]);
}
vector<int64> calculate_costs(vector<int> w,vector<int> a, vector<int> b, vector<int> e){
    int n = w.size(), q = e.size();
    if(n == 0){
        return vector<int64>(q, 0);
    }
    int sigma_a = 0;
    vector<artefak> item;
    for(int i = 0;i < n; i++){
        sigma_a += a[i];
        item.push_back({{w[i], a[i]}, {b[i], b[i]-a[i]}});
    }
    bool cek = 1;
    sort(item.begin(), item.end());
    vector<int64> ans(q, 0);
    vector<pi> q1,q2,que;
    for(int i = 0;i <n; i++){
        parent[i] = i;
        sz[i] = 1;
        val[i][i&1] = item.se.se;
        mx[i] = inf;
        val[i][(i+1)&1] = inf;
    }
    for(int i = 0; i < n-1; i++) q1.push_back({w[i+1]-w[i], i});
    for(int i = 1; i < n-1; i++) q2.push_back({w[i+1]-w[i-1], i});
    sort(q1.begin(), q1.end());
    sort(q2.begin(), q2.end());
    for(int i = 0; i < m; i++){
        que.push_back({e[i], i});
    }
    sort(que.begin(), que.end());
    int idx = 0, idx1 = 0;
    for(auto[d, i] : que){
        while(idx < q1.size() && q1[idx].fi <= d){
            int u = find(q1[idx].se), v = find(q1[idx].se+1);
            sigma_a += hitung(u)+hitung(v);
            parent[u] = v;
            sz[v] += sz[u];
            val[v][0] = max();
            val[v][1] = max();
            mx[v] = max(mx[v], mx[u]);
            sigma_a -= hitung(u);
            idx++;
        }
        while(idx1 < q2.size() && q2[idx1].fi <= d){
            int u = find(q2[idx1].se);
            sigma_a += hitung(u);
            mx[u] = max(mx[u], b[q2[idx1].se]-a[q2[idx1.se].se]);
            sigma_a -= hitung(u);
            idx1++;
        }
        ans[i] = sigma_a;
    }
    return ans;
}

Compilation message (stderr)

nile.cpp:9:23: warning: left shift count >= width of type [-Wshift-count-overflow]
    9 | const int64 inf = -(1 << 40);
      |                     ~~^~~~~
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:5:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >' has no member named 'second'
    5 | #define se second
      |            ^~~~~~
nile.cpp:39:28: note: in expansion of macro 'se'
   39 |         val[i][i&1] = item.se.se;
      |                            ^~
nile.cpp:47:24: error: 'm' was not declared in this scope
   47 |     for(int i = 0; i < m; i++){
      |                        ^
nile.cpp:58:28: error: no matching function for call to 'max()'
   58 |             val[v][0] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
nile.cpp:58:28: note:   candidate expects 2 arguments, 0 provided
   58 |             val[v][0] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
nile.cpp:58:28: note:   candidate expects 3 arguments, 0 provided
   58 |             val[v][0] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:62,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
nile.cpp:58:28: note:   candidate expects 1 argument, 0 provided
   58 |             val[v][0] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:62,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
nile.cpp:58:28: note:   candidate expects 2 arguments, 0 provided
   58 |             val[v][0] = max();
      |                         ~~~^~
nile.cpp:59:28: error: no matching function for call to 'max()'
   59 |             val[v][1] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
nile.cpp:59:28: note:   candidate expects 2 arguments, 0 provided
   59 |             val[v][1] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
nile.cpp:59:28: note:   candidate expects 3 arguments, 0 provided
   59 |             val[v][1] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:62,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
nile.cpp:59:28: note:   candidate expects 1 argument, 0 provided
   59 |             val[v][1] = max();
      |                         ~~~^~
In file included from /usr/include/c++/11/vector:62,
                 from nile.h:1,
                 from nile.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
nile.cpp:59:28: note:   candidate expects 2 arguments, 0 provided
   59 |             val[v][1] = max();
      |                         ~~~^~
nile.cpp:5:12: error: request for member 'second' in 'idx1', which is of non-class type 'int'
    5 | #define se second
      |            ^~~~~~
nile.cpp:67:57: note: in expansion of macro 'se'
   67 |             mx[u] = max(mx[u], b[q2[idx1].se]-a[q2[idx1.se].se]);
      |                                                         ^~