CSES - Datatähti 2020 alku - Results
Submission details
Task:Merkkijonot
Sender:Tempo
Submission time:2019-10-03 15:58:45 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:17:27: error: no matching function for call to 'std::vector<std::__cxx11::basic_string<char> >::push_back(int&)'
         inputs.push_back(i);
                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from input/code.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:939: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>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from 'int' to 'const value_type& {aka const std::__cxx11::basic_string<char>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp...

Code

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<string> inputs(n);
    vector<int> convertedInputs;

    for(int i=1; i<=n; i++)
    {
        int num;
        cin >> num;
        inputs.push_back(i);
    }

    for (auto i = inputs.begin(); i != inputs.end(); ++i)
        cout << *i << " ";

    return 0;
}