제출 #1224622

#제출 시각아이디문제언어결과실행 시간메모리
1224622sokratisiFrom Hacks to Snitches (BOI21_watchmen)C++20
컴파일 에러
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<pair<int, int>> q; q.push({1, 0}); // careful with staying still while (!q.empty()) { int node = q.front().first, tm = q.front().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; }

컴파일 시 표준 에러 (stderr) 메시지

watchmen.cpp: In function 'int main()':
watchmen.cpp:41:45: error: expected primary-expression before ')' token
   41 |             if (!vis[u][tm+1] && /*fill in*/) {
      |                                             ^
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]);
      |                                 ~~~~~^~~~~~~~~~~~~~