Submission #1224620

#TimeUsernameProblemLanguageResultExecution timeMemory
1224620sokratisiFrom Hacks to Snitches (BOI21_watchmen)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n, m, k, a, b, l; vector<int> adj[100010]; int cl[130], dst[100010][130]; bool vis[100010][130]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d%d", &a, &b); adj[a].push_back(b); adj[b].push_back(a); } scanf("%d%d", &k, &l); for (int i = 0; i < l; i++) scanf("%d", &cl[i]); cl[l] = cl[0]; for (int i = 1; i <= n; i++) { for (int j = 0; j < l; j++) { dst[i][j] = -1; } } dst[1][0] = 0; queue<int> q; q.push({1, 0}); // careful with staying still while (!q.empty()) { int node = q.top().first, tm = q.top().second; q.pop(); if (vis[node][tm]) continue; vis[node][tm] = true; if (!vis[node][(tm+1)%l] && cl[tm+1] != node) { q.push({node, (tm+1)%l}); dst[node][(tm+1)%l] = dst[node][tm] + 1; } for (auto u: adj[node]) { if (!vis[u][tm+1] && /*fill in*/) { q.push({u, (tm+1)%l}); dst[u][(tm+1)%l] = dst[node][tm] + 1; } } } if (dst[n][0] == INT_MAX) printf("impossible\n"); else { int ans = INT_MAX; for (int j = 0; j < l; j++) ans = min(ans, dst[n][j]); printf("%d\n", ans); } return 0; }

Compilation message (stderr)

watchmen.cpp: In function 'int main()':
watchmen.cpp:29:11: error: no matching function for call to 'std::queue<int>::push(<brace-enclosed initializer list>)'
   29 |     q.push({1, 0});
      |     ~~~~~~^~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from watchmen.cpp:1:
/usr/include/c++/11/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>::value_type&&' {aka 'int&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
watchmen.cpp:32:22: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   32 |         int node = q.top().first, tm = q.top().second;
      |                      ^~~
      |                      pop
watchmen.cpp:34:25: error: expected primary-expression before ']' token
   34 |         if (vis[node][tm]) continue;
      |                         ^
watchmen.cpp:35:21: error: expected primary-expression before ']' token
   35 |         vis[node][tm] = true;
      |                     ^
watchmen.cpp:36:27: error: expected primary-expression before '+' token
   36 |         if (!vis[node][(tm+1)%l] && cl[tm+1] != node) {
      |                           ^
watchmen.cpp:36:42: error: expected primary-expression before '+' token
   36 |         if (!vis[node][(tm+1)%l] && cl[tm+1] != node) {
      |                                          ^
watchmen.cpp:37:30: error: expected primary-expression before '+' token
   37 |             q.push({node, (tm+1)%l});
      |                              ^
watchmen.cpp:37:19: error: no matching function for call to 'std::queue<int>::push(<brace-enclosed initializer list>)'
   37 |             q.push({node, (tm+1)%l});
      |             ~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from watchmen.cpp:1:
/usr/include/c++/11/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>::value_type&&' {aka 'int&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
watchmen.cpp:38:26: error: expected primary-expression before '+' token
   38 |             dst[node][(tm+1)%l] = dst[node][tm] + 1;
      |                          ^
watchmen.cpp:38:47: error: expected primary-expression before ']' token
   38 |             dst[node][(tm+1)%l] = dst[node][tm] + 1;
      |                                               ^
watchmen.cpp:41:27: error: expected primary-expression before '+' token
   41 |             if (!vis[u][tm+1] && /*fill in*/) {
      |                           ^
watchmen.cpp:41:45: error: expected primary-expression before ')' token
   41 |             if (!vis[u][tm+1] && /*fill in*/) {
      |                                             ^
watchmen.cpp:42:31: error: expected primary-expression before '+' token
   42 |                 q.push({u, (tm+1)%l});
      |                               ^
watchmen.cpp:42:23: error: no matching function for call to 'std::queue<int>::push(<brace-enclosed initializer list>)'
   42 |                 q.push({u, (tm+1)%l});
      |                 ~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from watchmen.cpp:1:
/usr/include/c++/11/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>::value_type&&' {aka 'int&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
watchmen.cpp:43:27: error: expected primary-expression before '+' token
   43 |                 dst[u][(tm+1)%l] = dst[node][tm] + 1;
      |                           ^
watchmen.cpp:43:48: error: expected primary-expression before ']' token
   43 |                 dst[u][(tm+1)%l] = dst[node][tm] + 1;
      |                                                ^
watchmen.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
watchmen.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d%d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~
watchmen.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d%d", &k, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~
watchmen.cpp:18:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     for (int i = 0; i < l; i++) scanf("%d", &cl[i]);
      |                                 ~~~~~^~~~~~~~~~~~~~