Task: | Lehmät |
Sender: | Kreebox1 |
Submission time: | 2022-11-13 21:43:41 +0200 |
Language: | C++ (C++11) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:24:24: error: no matching function for call to 'std::vector<std::__cxx11::basic_string<char> >::push_back(std::vector<std::__cxx11::basic_string<char> >&)' 24 | arvot.push_back(foo); | ~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/11/vector:67, from input/code.cpp:2: /usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::value_type = std::__cxx11::basic_string<char>]' 1187 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1187:35: note: no known conversion for argument 1 from 'std::vector<std::__cxx11::basic_string<char> >' to 'const value_type&' {aka 'const std::__cxx11::basic_string<char>&'} 1187 | push_back(const...
Code
#include <iostream> #include <vector> #include <sstream> #include <string> using namespace std; int main() { int n, m, s = 0, e = 0, count = 0; // kartan korkeus ja leveys bool check = false; vector <string> arvot; cin >> n >> m; arvot.resize(n*m); for (int i = 0; i < n; i++) { vector<string> foo; string temp, std; getline(cin, std); istringstream ss(std); while (ss >> temp) { foo.push_back(temp); } arvot.push_back(foo); } for (int y = 0; y < n; y++) { for (int x = 0; x < m; x++) { if (arvot[y][x] == "*" && s == 0) { s = x; } else if (arvot[y][x] == "." && arvot[y][x-1] == "*" && e == 0 && count >= ) { e = x; } else if (arvot[y][x] == "@" && x > s && x < e && check) { count++; } else if (e != 0 && s != 0 && arvot[y][x] == "*") { check = true; } else if(arvot[y][x] == "." && check) { check = false; } } cout << count << "\n"; }