Submission #1171338

#TimeUsernameProblemLanguageResultExecution timeMemory
1171338gulmixSeptember (APIO24_september)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()
#define oset tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>

const ll MOD = 1e9 + 7, N = 2e5 + 5;
vector<ll> graph[N];
ll dp[N];

void dfs(ll v, ll p){
    for(auto u: graph[v]){
        if(u != p){
            dfs(u, v);
            dp[v] = max(dp[v], dp[u]);
        }
    }
}

ll solve(ll n, ll m, vector<ll> g, vector<vector<ll>> rec){
    for(int i = 1; i < n; i++){
        graph[i].push_back(g[i]);
        graph[g[i]].push_back(i);
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n-1; j++){
            dp[rec[i][j]] = max(dp[rec[i][j]], j);
        }
    }
    dfs(0, -1);
    ll last = -1, ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(last < i)ans++;
        ll mx = 0;
        for(int j = 0; j < m; j++){
            mx = max(mx, dp[rec[j][i]]);
        }
        last = max(last, mx);
    }
    for(int i = 0; i < n; i++){
        graph[i].clear();
        dp[i] = 0;
    }
    return ans;
}

//int main(){
//    ios::sync_with_stdio(false);
//    cin.tie(0); 
//    //ifstream cin("fstncd.in");
//    //ofstream cout("fstncd.out");
//    
//}

Compilation message (stderr)

september.cpp: In function 'll solve(ll, ll, std::vector<long long int>, std::vector<std::vector<long long int> >)':
september.cpp:31:32: error: no matching function for call to 'max(ll&, int&)'
   31 |             dp[rec[i][j]] = max(dp[rec[i][j]], j);
      |                             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from september.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:
september.cpp:31:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |             dp[rec[i][j]] = max(dp[rec[i][j]], j);
      |                             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from september.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:
september.cpp:31:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |             dp[rec[i][j]] = max(dp[rec[i][j]], j);
      |                             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from september.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:
september.cpp:31:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |             dp[rec[i][j]] = max(dp[rec[i][j]], j);
      |                             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from september.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:
september.cpp:31:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |             dp[rec[i][j]] = max(dp[rec[i][j]], j);
      |                             ~~~^~~~~~~~~~~~~~~~~~