Submission #1312233

#TimeUsernameProblemLanguageResultExecution timeMemory
1312233azamurai9월 (APIO24_september)C++20
Compilation error
0 ms0 KiB
#include "september.h" #include <vector> using namespace std; int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { int ans = 0; vector <int> colour(N, 0); vector <vector<int>> g[N]; for (int i = 0; i < N; i++) { if (F[i] != -1) { g[F[i]].push_back(i); } } for (int i = 0; i < N - 1; i++) { int v = s[0][i]; int ok = 1; for (auto to : g[v]) { if (!colour[to]) ok = 0; } if (ok) { colour[v] = 1; } else { return i; } } return N - 1; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:13:42: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(int&)'
   13 |                         g[F[i]].push_back(i);
      |                         ~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/13/vector:66,
                 from september.h:1,
                 from september.cpp:1:
/usr/include/c++/13/bits/stl_vector.h:1281:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; value_type = std::vector<int>]'
 1281 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:35: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<int> >::value_type&' {aka 'const std::vector<int>&'}
 1281 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1298:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; value_type = std::vector<int>]'
 1298 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1298:30: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1298 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
september.cpp:17:25: error: 's' was not declared in this scope
   17 |                 int v = s[0][i];
      |                         ^
september.cpp:20:36: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
   20 |                         if (!colour[to]) ok = 0;
      |                                    ^
/usr/include/c++/13/bits/stl_vector.h:1126:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1126:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1145:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1145:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~