Submission #1228382

#TimeUsernameProblemLanguageResultExecution timeMemory
1228382JerRailway Trip 2 (JOI22_ho_t4)C++20
8 / 100
30 ms840 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 305; int dist[MAXN][MAXN]; int n, k, m, q; int main() { scanf("%d%d%d", &n, &k, &m); int a, b; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) dist[i][j] = (i == j) ? 0 : INT_MAX; for (int i = 0; i < m; i++) { scanf("%d%d", &a, &b); a--, b--; if (a < b) { for (int s = a; s <= min(a + k - 1, b - 1); s++) for (int j = s + 1; j <= b; j++) dist[s][j] = 1; } else { for (int s = a; s >= max(a - k + 1, b + 1); s--) for (int j = s - 1; j >= b; j--) dist[s][j] = 1; } } for (int x = 0; x < n; x++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (dist[i][x] != INT_MAX and dist[x][j] != INT_MAX and dist[i][x] + dist[x][j] < dist[i][j]) dist[i][j] = dist[i][x] + dist[x][j]; scanf("%d", &q); while (q--) { int s, t; scanf("%d%d", &s, &t); s--, t--; printf("%d\n", (dist[s][t] == INT_MAX) ? -1 : dist[s][t]); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d%d%d", &n, &k, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%d%d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%d%d", &s, &t);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...