Submission #648336

# Submission time Handle Problem Language Result Execution time Memory
648336 2022-10-06T07:41:12 Z Trisanu_Das Jetpack (COCI16_jetpack) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

vector<int>res;
char tab[20][100010];
int n;
int dfs(int l,int c){
    if(tab[l][c]=='X')return 0;
    if(c==n-1)return 1;
    tab[l][c]='X';
    if(dfs(min(9,l+1),c+1) == 1) return 1;
    else if(dfs(max(0,l-1),c+1) == 1){
        res.push_back(c);
        return 1;
    }
    return 0;
}
int main(){
    cin >> n;
    for(int i=0;i<10;i++) cin >> tab[i];
    dfs(9,0);
    reverse(res.begin(),res.end());
    cout << res.size << '\n';
    for(int i = 0;i < res.size(); i++) cout << res[i] << ' ' << 1 << '\n';;
    return 0;
}

Compilation message

jetpack.cpp: In function 'int main()':
jetpack.cpp:23:10: error: invalid use of non-static member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   23 |     cout << res.size << '\n';
      |     ~~~~~^~~~~~~~~~~
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 jetpack.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:918:7: note: declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
jetpack.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0;i < res.size(); i++) cout << res[i] << ' ' << 1 << '\n';;
      |                   ~~^~~~~~~~~~~~