제출 #1107279

#제출 시각아이디문제언어결과실행 시간메모리
1107279vjudge1은행 (IZhO14_bank)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define nn "\n"; #define pb push_back #define all(v) (v).begin() , (v).end() const int N = 2e5+ 4; int n , T , q , m ; signed main(){ cin>> n >> m ; int a[n+1] , b[m] , ok =0 ; for(int i= 1 ; i <= n ;i++)cin>> a[i]; for(int i =0 ; i < m; i++)cin>> b[i]; vector<vector<vector<int>>>mp[25000]; for(int j = 0 ; j < (1 << m )- 1; j++){ int x =0 ; vector<int>v; for(int u =0 ; u < m ; u++){ if((j >> u )&1){ x+=b[u]; v.pb(b[u]); } } mp[x].pb(v); } queue<pair<int , map<int, int >>>q; map<int ,int >h; for(int i =0 ; i < m ; i++){ h[b[i]]++; } q.push({1 , h }); while(q.size()){ pair<int , map<int , int >> p= q.front(); q.pop(); int v = p.first ; map<int ,int >us = p.second; for(auto it:mp[a[v]]){ int ko =0 ; for(auto at:it){ if(us[at])ko++; us[at]--; } if(ko== it.size()){ if(v == n ){ cout << "YES"; return 0 ; } q.push({v + 1 ,us}); } for(auto at:it){ us[at]++; } } } cout << "NO"; }

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

bank.cpp: In function 'int main()':
bank.cpp:24:23: error: no matching function for call to 'std::vector<std::vector<std::vector<long long int> > >::push_back(std::vector<long long int>&)'
   24 |             mp[x].pb(v);
      |                       ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bank.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::vector<long long int> >; _Alloc = std::allocator<std::vector<std::vector<long long int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::vector<long long int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const value_type&' {aka 'const std::vector<std::vector<long long int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::vector<long long int> >; _Alloc = std::allocator<std::vector<std::vector<long long int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::vector<long long int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<std::vector<std::vector<long long int> > >::value_type&&' {aka 'std::vector<std::vector<long long int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
bank.cpp:40:22: error: no match for 'operator[]' (operand types are 'std::map<long long int, long long int>' and 'std::vector<long long int>')
   40 |                 if(us[at])ko++;
      |                      ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from bank.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const key_type&' {aka 'const long long int&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
bank.cpp:41:19: error: no match for 'operator[]' (operand types are 'std::map<long long int, long long int>' and 'std::vector<long long int>')
   41 |                 us[at]--;
      |                   ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from bank.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const key_type&' {aka 'const long long int&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
bank.cpp:43:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             if(ko== it.size()){
      |                ~~^~~~~~~~~~~~
bank.cpp:51:23: error: no match for 'operator[]' (operand types are 'std::map<long long int, long long int>' and 'std::vector<long long int>')
   51 |                     us[at]++;
      |                       ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from bank.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const key_type&' {aka 'const long long int&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = long long int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = long long int]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::map<long long int, long long int>::key_type&&' {aka 'long long int&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
bank.cpp:11:25: warning: unused variable 'ok' [-Wunused-variable]
   11 |     int a[n+1] , b[m] , ok =0 ;
      |                         ^~