제출 #1223088

#제출 시각아이디문제언어결과실행 시간메모리
1223088poatBitaro’s Party (JOI18_bitaro)C++17
컴파일 에러
0 ms0 KiB
// #pragma GCC optimize("Ofast") // #pragma GCC target("popcnt") #include <bits/stdc++.h> using namespace std; // #define int long long // #define double long double #define mkp make_pair #define txt freopen("shortcut.in", "r", stdin), freopen("shortcut.out", "w", stdout); const int N = 2e5 + 100, K = 150, inf = 0, mod = 1e9 + 7; const double eps = 1e-6; vector<int> gr[N]; set<pair<int, int>> S[N]; set<pair<int, int>> R[N]; int D[N]; void solve() { int n, m, Q; cin >> n >> m >> Q; for(int i = m, a, b; i--;) { cin >> a >> b; gr[a].push_back(b); } for(int i = 1; i <= n; i++) { S[i].insert({0, i}); R[i].insert({i, 0}); } for(int i = 1; i <= n; i++) { for(auto x : gr[i]) { for(auto j : R[i]) { auto it = R[x].lower_bound({j.first, 0}); if(it != R[x].end() && it->first == j.first) { pair<int, int> p = *it; R[x].erase(it); S[x].erase({p.second, p.first}); p = max(p, {j.first, j.second + 1}); R[x].insert(p); S[x].insert({p.second, p.first}); } else { R[x].insert({j.first, j.second + 1}); S[x].insert({j.second + 1, j.first}); } } while(S[x].size() > K) { R[x].erase({S[x].begin()->second, S[x].begin()->first}); S[x].erase(S[x].begin()); } } } for(int qq = Q, x, y; qq--;) { cin >> x >> y; vector<int> vec(y); for(auto &i : vec) { cin >> i; D[i] = -1e9; } if(y < K) { int mx = -1; for(auto i : S[x]) { if(D[i.second] >= 0) mx = i.first; } cout << mx << "\n"; } else { for(int i = 1; i <= n; i++) { for(auto j : gr[i]) D[j] = max(D[j], D[i] + 1); } cout << max(-1ll, D[x]) << '\n'; for(int i = 1; i <= n; i++) D[i] = 0; } for(auto i : vec) D[i] = 0; } } signed main() { // txt; ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int T = 1; for(; T--; solve()); } /* */

컴파일 시 표준 에러 (stderr) 메시지

bitaro.cpp: In function 'void solve()':
bitaro.cpp:99:24: error: no matching function for call to 'max(long long int, int&)'
   99 |             cout << max(-1ll, D[x]) << '\n';
      |                     ~~~^~~~~~~~~~~~
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 bitaro.cpp:4:
/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:
bitaro.cpp:99:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   99 |             cout << max(-1ll, D[x]) << '\n';
      |                     ~~~^~~~~~~~~~~~
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 bitaro.cpp:4:
/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:
bitaro.cpp:99:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   99 |             cout << max(-1ll, D[x]) << '\n';
      |                     ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bitaro.cpp:4:
/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:
bitaro.cpp:99:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   99 |             cout << max(-1ll, D[x]) << '\n';
      |                     ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bitaro.cpp:4:
/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:
bitaro.cpp:99:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   99 |             cout << max(-1ll, D[x]) << '\n';
      |                     ~~~^~~~~~~~~~~~