제출 #992212

#제출 시각아이디문제언어결과실행 시간메모리
992212vivkostovBitaro’s Party (JOI18_bitaro)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define endl "\n" using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n,m,qu,a,b,x,y,used[200005]; vector<int>v[200005],c; void bfs(int beg) { used[beg]=1; int w,nb; queue<int>q; q.push(beg); //cout<<beg<<endl; while(!q.empty()) { w=q.front(); q.pop(); //cout<<w<<" "<<beg<<endl; for(int i=0; i<(int)(v[w].size()); i++) { nb=v[w][i]; q.push(nb); used[nb]=max(used[nb,used[w]+1); } } } void read() { cin>>n>>m>>qu; for(int i=1; i<=m; i++) { cin>>a>>b; v[b].push_back(a); } cin>>x>>y; for(int j=1; j<=y; j++) { int h; cin>>h; c.push_back(h); } bfs(x); int ma=0,num=0; for(int j=1; j<=n; j++) { //cout<<used[j]<<" "<<j<<endl; if(num==(int)(c.size())||j!=c[num])ma=max(ma,used[j]-1); else num++; } cout<<ma<<endl; } int main() { speed(); read(); return 0; }

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

bitaro.cpp: In function 'void bfs(int)':
bitaro.cpp:28:31: warning: left operand of comma operator has no effect [-Wunused-value]
   28 |             used[nb]=max(used[nb,used[w]+1);
      |                               ^~
bitaro.cpp:28:43: error: expected ']' before ')' token
   28 |             used[nb]=max(used[nb,used[w]+1);
      |                                           ^
      |                                           ]
bitaro.cpp:28:43: error: no matching function for call to 'max(int&)'
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:28:43: note:   candidate expects 2 arguments, 1 provided
   28 |             used[nb]=max(used[nb,used[w]+1);
      |                                           ^
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:28:43: note:   candidate expects 3 arguments, 1 provided
   28 |             used[nb]=max(used[nb,used[w]+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:28:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |             used[nb]=max(used[nb,used[w]+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:28:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |             used[nb]=max(used[nb,used[w]+1);
      |                                           ^