Submission #1016980

#TimeUsernameProblemLanguageResultExecution timeMemory
1016980ThommyDBBitaro’s Party (JOI18_bitaro)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>

using namespace std;
#define int long long

int N, M, Q;
vector<pair<int, int>> Canals;
vector<vector<int>> adj;
vector<int> T, Y;
vector<vector<int>> C;
vector<vector<int>> dp;

void dfs(int x){
    if(dp[x][x]==0)return;
    dp[x][x]=0;
    for(auto u : adj[x]){
        dfs(u);
        dp[x][u]= max(dp[x][u], 1);
        for(int i = x+1; i < N; i++){
            if(dp[u][i]==-1)continue;
            dp[x][i] = max(dp[x][i], dp[u][i]+1);
        }
    }
}

signed main(){
    cin >> N >> M >> Q;
    Canals.resize(M);
    adj.resize(N);
    dp.resize(N, vector<int>(N, -1));
    for(int i = 0; i < M; i++){
        cin >> Canals[i].first >> Canals[i].second;
        Canals[i].first--; Canals[i].second--;
        adj[Canals[i].first].push_back(Canals[i].second);
    }
    for(int i = 0; i < N; i++){
        if(dp[i][i]!=-1)continue;
        dfs(i);
    }
    

    /*for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cout << i << " -> " << j << " = " << dp[i][j] << "\n";
        }
    }*/

    T.resize(Q);
    Y.resize(Q);
    C.resize(Q);
    vector<bool> TooBusy(N, false);
    for(int i = 0; i < Q; i++){
        fill(TooBusy.begin(), TooBusy.end(), false);
        cin >> T[i] >> Y[i];
        T[i]--;
        C[i].resize(Y[i]);
        for(int j = 0; j < Y[i]; j++){
            cin >> C[i][j];
            C[i][j]--;
            TooBusy[C[i][j]]=true;
        }
        int ans = -1;
        for(int j = 0; j < N; j++){
            //cout << i << " && " << T[i] << "\n";
            if(TooBusy[j])continue;
            ans = max(ans, dp[j][T[i]]);
        }
        cout << ans << "\n";
    }
}

Compilation message (stderr)

bitaro.cpp: In function 'void dfs(long long int)':
bitaro.cpp:18:34: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)'
   18 |         dp[x][u]= max(dp[x][u], 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 bitaro.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:
bitaro.cpp:18:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         dp[x][u]= max(dp[x][u], 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 bitaro.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:
bitaro.cpp:18:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         dp[x][u]= max(dp[x][u], 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 bitaro.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:
bitaro.cpp:18:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         dp[x][u]= max(dp[x][u], 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 bitaro.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:
bitaro.cpp:18:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         dp[x][u]= max(dp[x][u], 1);
      |                                  ^