제출 #880944

#제출 시각아이디문제언어결과실행 시간메모리
880944Younis_Dwai은행 (IZhO14_bank)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define in insert #define F first #define S second #define pb push_back #define endl "\n" //#define mid (l+r)/2 #define all(v) v.begin(),v.end() //#define pop pop_back using namespace std; using std::cout; const int M=1e9+7; int n,m; int a[25],b[25]; int dp[24][3000009]; vector<int> adj[200009]; int rec(int id , int mask){ if(dp[id][mask]!=-1) return dp[id][mask]; else if(id==n) return 1; bool c=0; for(auto u : adj[a[id]]){ if((mask&u)) continue ; c=max(c,rec(id+1,(mask|u))); if(c==1) break; } return dp[id][mask]=c; } int32_t main(){ memset(dp,-1,sizeof dp); cin>>n>>m; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<m;i++) cin>>b[i]; for(int mask=1;mask<(1<<m);mask++){ int sum=0; for(int i=0;i<m;i++){ if((mask&(1<<i))) sum+=b[i]; } adj[sum].pb(mask); } if(rec(0,0)==1) cout<<"YES"; else cout<<"NO"; return 0; }

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

bank.cpp: In function 'long long int rec(long long int, long long int)':
bank.cpp:24:39: error: no matching function for call to 'max(bool&, long long int)'
   24 |             c=max(c,rec(id+1,(mask|u)));
      |                                       ^
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 bank.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:
bank.cpp:24:39: note:   deduced conflicting types for parameter 'const _Tp' ('bool' and 'long long int')
   24 |             c=max(c,rec(id+1,(mask|u)));
      |                                       ^
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 bank.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:
bank.cpp:24:39: note:   deduced conflicting types for parameter 'const _Tp' ('bool' and 'long long int')
   24 |             c=max(c,rec(id+1,(mask|u)));
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bank.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:
bank.cpp:24:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'bool'
   24 |             c=max(c,rec(id+1,(mask|u)));
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bank.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:
bank.cpp:24:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'bool'
   24 |             c=max(c,rec(id+1,(mask|u)));
      |                                       ^