Submission #774073

#TimeUsernameProblemLanguageResultExecution timeMemory
774073jasminPrisoner Challenge (IOI22_prison)C++17
Compilation error
0 ms0 KiB
#include "prison.h" #include<bits/stdc++.h> using namespace std; std::vector<std::vector<int>> devise_strategy(int n) { vector<int> ans(n+1, -1); ans[0][0]=0; for(int i=1; i<=n; i++){ ans[i][0]=1; } for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ if(j<i){ ans[i][j]=-2; } else{ ans[i][j]=-1; } } } return ans; }

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:9:11: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    9 |     ans[0][0]=0;
      |           ^
prison.cpp:11:15: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   11 |         ans[i][0]=1;
      |               ^
prison.cpp:18:23: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   18 |                 ans[i][j]=-2;
      |                       ^
prison.cpp:21:23: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   21 |                 ans[i][j]=-1;
      |                       ^
prison.cpp:27:12: error: could not convert 'ans' from 'vector<int>' to 'vector<std::vector<int>>'
   27 |     return ans;
      |            ^~~
      |            |
      |            vector<int>