Submission #735614

#TimeUsernameProblemLanguageResultExecution timeMemory
735614math_rabbit_1028Radio Towers (IOI22_towers)C++17
Compilation error
0 ms0 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; int n; vector<int> arr; int cnt[101010]; void init(int N, vector<int> H) { n = N; for (int i = 0; i < N; i++) arr.push_back(H); cnt[0] = 0; for (int i = 1; i < N; i++) { if (arr[i] > arr[i - 1] && arr[i] > arr[i + 1]) cnt[i] = cnt[i - 1] + 1; } } int max_towers(int L, int R, int D) { return cnt[R - 1] - cnt[L] + 1; }

Compilation message (stderr)

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:11:46: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   11 |   for (int i = 0; i < N; i++) arr.push_back(H);
      |                                              ^
In file included from /usr/include/c++/10/vector:67,
                 from towers.h:1,
                 from towers.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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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<int>' to 'const value_type&' {aka 'const 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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~