Submission #111565

# Submission time Handle Problem Language Result Execution time Memory
111565 2019-05-15T15:44:21 Z TAISA_ Bitaro’s Party (JOI18_bitaro) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> v, in(n);
    vector<vector<int>> G(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        in[b]++;
    }
    stack<int> st;
    for(int i = 0; i < n; i++) {
        if(in[i] == 0) {
            st.push(i);
        }
    }
    while(!st.empty()) {
        int i = st.top();
        v.push_back(i);
        st.pop();
        for(auto e : G[i]) {
            in[e]--;
            if(in[e] == 0) {
                st.push(e);
            }
        }
    }
    int sq = sqrt(100000) - 100;
    auto dp = make_v<int>(n, sq + 1);
    auto idx = make_v<int>(n, sq + 1);
    fill_v(dp, -INF);
    fill_v(idx, -1);
    vector<int> sz(n), vis(n);
    for(int i = 0; i < n; i++) {
        dp[i][0] = 0;
        idx[i][0] = i;
        sz[i] = 1;
    }
    for(auto i : v) {
        for(auto e : G[i]) {
            vector<int> ndp(sq + 1, -INF), nid(sq + 1, -1);
            int a = 0, b = 0, t = 0;
            while(a < sz[i] || b < sz[e]) {
                if(t >= sq) {
                    break;
                }
                while(a < sz[i] && vis[idx[i][a]]) {
                    a++;
                }
                while(b < sz[e] && vis[idx[e][b]]) {
                    b++;
                }
                if(a >= sz[i] && b >= sz[e]) {
                    break;
                }
                if(a >= sz[i]) {
                    ndp[t] = dp[e][b];
                    nid[t] = idx[e][b];
                    b++;
                } else if(b >= sz[e] || dp[i][a] + 1 > dp[e][b]) {
                    ndp[t] = dp[i][a] + 1;
                    nid[t] = idx[i][a];
                    a++;
                } else {
                    ndp[t] = dp[e][b];
                    nid[t] = idx[e][b];
                    b++;
                }
                vis[nid[t]] = 1;
                t++;
            }
            sz[e] = t;
            for(int j = 0; j < t; j++) {
                dp[e][j] = ndp[j];
                idx[e][j] = nid[j];
                vis[nid[j]] = 0;
            }
        }
    }
    while(q--) {
        int t, y;
        cin >> t >> y;
        --t;
        vector<int> c(y);
        for(int i = 0; i < y; i++) {
            cin >> c[i];
            --c[i];
            vis[c[i]] = 1;
        }
        int ans = -INF;
        if(y <= sq) {
            for(int i = 0; i <= sq; i++) {
                if(!vis[idx[t][i]]) {
                    ans = dp[t][i];
                    break;
                }
            }
        } else {
            vector<int> dp2(n, -INF);
            for(auto i : v) {
                if(!vis[i]) {
                    chmax(dp2[i], 0);
                }
                for(auto e : G[i]) {
                    chmax(dp2[e], dp2[i] + 1);
                }
            }
            ans = dp2[t];
        }
        cout << max(ans, -1LL) << "\n";
        for(int i = 0; i < y; i++) {
            vis[c[i]] = 0;
        }
    }
}

Compilation message

bitaro.cpp: In function 'int main()':
bitaro.cpp:165:30: error: no matching function for call to 'max(int&, long long int)'
         cout << max(ans, -1LL) << "\n";
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from bitaro.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
bitaro.cpp:165:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
         cout << max(ans, -1LL) << "\n";
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from bitaro.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
bitaro.cpp:165:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
         cout << max(ans, -1LL) << "\n";
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from bitaro.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
bitaro.cpp:165:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         cout << max(ans, -1LL) << "\n";
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from bitaro.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
bitaro.cpp:165:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         cout << max(ans, -1LL) << "\n";
                              ^