제출 #711784

#제출 시각아이디문제언어결과실행 시간메모리
711784mseebacher버섯 세기 (IOI20_mushrooms)C++17
컴파일 에러
0 ms0 KiB
#include "mushrooms.h" #include<bits/stdc++.h> #define ll long long using namespace std; int count_mushrooms(int n){ vector<int> a(2); a[0] = 0; a[1] = 1; if(n == 1) return 1; if(n == 2) return use_machine(a) == 1 ? 1 : 2; a.assign(3); a[1] = 0; int ans = 1; for(int i = 1;i<n-1;i+=2){ a[0] = i; a[2] = i+1; int x = use_machine(a); if(x == 0) ans+=2; if(x == 1) ans++; } return ans; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:13:13: error: no matching function for call to 'std::vector<int>::assign(int)'
   13 |   a.assign(3);
      |             ^
In file included from /usr/include/c++/10/vector:67,
                 from mushrooms.h:1,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:749:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:768:2: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]'
  768 |  assign(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note:   template argument deduction/substitution failed:
mushrooms.cpp:13:13: note:   candidate expects 2 arguments, 1 provided
   13 |   a.assign(3);
      |             ^
In file included from /usr/include/c++/10/vector:67,
                 from mushrooms.h:1,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:794:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  794 |       assign(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~