제출 #736583

#제출 시각아이디문제언어결과실행 시간메모리
736583browntoadBitaro’s Party (JOI18_bitaro)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long // #define int ll #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, n+1) #define RREP(i, n) for (int i=(n)-1; i>=0; i--) #define pii pair<int, int> #define f first #define s second #define pii pair<int, int> #define f first #define s second #define pb push_back #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) const ll maxn = 2e5+5; const ll inf = (1ll<<60); const int iinf = 2147483647; int n, m, qq; struct quer{ int nd; vector<int> ban; int id; }; vector<int> ans(maxn), topo(maxn), ind(maxn); vector<int> tp; vector<int> graph[maxn]; vector<pii> kth[maxn]; const int bloc = 85; vector<quer> q1, q2; void init(){ queue<int> qu; int cnt = 1; REP1(i, n){ if (ind[i] == 0){ qu.push(i); } } while(qu.size()){ int x = qu.front(); qu.pop(); topo[x] = cnt; tp.pb(x); cnt++; REP(i, SZ(graph[x])){ ind[graph[x][i]]--; if (ind[graph[x][i]] == 0){ qu.push(graph[x][i]); } } } } void proc1(){ REP1(i, n) kth[i].pb({0, i}); REP(i, SZ(tp)){ int x = tp[i]; sort(ALL(kth[x])); reverse(ALL(kth[x])); REP(j, SZ(graph[x])){ REP(l, min(SZ(kth[x]), bloc)){ kth[graph[x][j]].pb({kth[x][l].f+1, kth[x][l].s}); } } } vector<bool> no(n+1); REP(i, SZ(q1)){ REP(j, SZ(q1[i].ban)){ no[q1[i].ban[j]] = true; } int res = iinf; REP(j, SZ(kth[q1[i].nd])){ if (no[kth[q1[i].nd][j].s]) continue; res = kth[q1[i].nd][j].f; break; } if (res == iinf) res = -1; ans[q1[i].id] = res; REP(j, SZ(q1[i].ban)){ no[q1[i].ban[j]] = false; } } } void proc2(){ vector<int> dis(n+1); vector<bool> no(n+1); REP(i, SZ(q2)){ REP(j, SZ(q2[i].ban)){ no[q2[i].ban[j]] = true; } REP(j, topo[q2[i].nd]){ dis[tp[j]] = -iinf; } REP(j, topo[q2[i].nd]){ int x = tp[j]; if (!no[x]){ dis[x] = max(dis[x], 0ll); } REP(k, SZ(graph[x])){ if (topo[graph[x][k]] > topo[q2[i].nd]) break; // pruning dis[graph[x][k]] = max(dis[x]+1, dis[graph[x][k]]); } } if (dis[q2[i].nd] < 0) dis[q2[i].nd] = -1; ans[q2[i].id] = dis[q2[i].nd]; REP(j, SZ(q2[i].ban)){ no[q2[i].ban[j]] = false; } } } bool cmp(int a, int b){ return topo[a]<topo[b]; } signed main(){ ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin>>n>>m>>qq; REP(i, m){ int u, v; cin>>u>>v; graph[u].pb(v); ind[v]++; } init(); REP1(i, n) { sort(ALL(graph[i]), cmp); } REP(i, qq){ int ndd; cin>>ndd; int k; cin>>k; vector<int> bban; REP(j, k){ int x; cin>>x; bban.pb(x); } sort(ALL(bban)); if (SZ(bban)<=80){ q1.pb({ndd, bban, i}); } else q2.pb({ndd, bban, i}); } proc1(); proc2(); REP(i, qq){ cout<<ans[i]<<endl; } }

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

bitaro.cpp: In function 'void proc2()':
bitaro.cpp:99:41: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int)'
   99 |                 dis[x] = max(dis[x], 0ll);
      |                                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:99:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   99 |                 dis[x] = max(dis[x], 0ll);
      |                                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:99:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   99 |                 dis[x] = max(dis[x], 0ll);
      |                                         ^
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:99:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   99 |                 dis[x] = max(dis[x], 0ll);
      |                                         ^
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:99:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   99 |                 dis[x] = max(dis[x], 0ll);
      |                                         ^