Submission #1225809

#TimeUsernameProblemLanguageResultExecution timeMemory
1225809paskalisapoPainting Walls (APIO20_paint)C++20
Compilation error
0 ms0 KiB
#include "paint.h" #include <vector> int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { vector<int> colourlike(K , -1); for(int i = 0 ;i < M ; i++) { for(auto &x : B[i]) { colourlike[x] = i; } } int index = 0; int instr = 0; while(index < N) { if(colourlike[C[index]] == -1) { return -1; } int start = colourlike[C[index]]; int cur = start + 1; index++; while(cur <= start + M && index < N) { if(colourlike[C[index]] != cur) { return -1; } index++; cur++; } instr++; } return instr; }

Compilation message (stderr)

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> colourlike(K , -1);
      |     ^~~~~~
paint.cpp:9:5: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from paint.h:1,
                 from paint.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from paint.h:1,
                 from paint.cpp:1:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
paint.cpp:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> colourlike(K , -1);
      |            ^~~
paint.cpp:12:13: error: 'colourlike' was not declared in this scope
   12 |             colourlike[x] = i;
      |             ^~~~~~~~~~
paint.cpp:19:12: error: 'colourlike' was not declared in this scope
   19 |         if(colourlike[C[index]] == -1) {
      |            ^~~~~~~~~~
paint.cpp:22:21: error: 'colourlike' was not declared in this scope
   22 |         int start = colourlike[C[index]];
      |                     ^~~~~~~~~~