Submission #528246

#TimeUsernameProblemLanguageResultExecution timeMemory
528246rainboyAutobus (COCI22_autobus)C11
70 / 70
137 ms1632 KiB
#include <stdio.h> #include <string.h> #define N 70 #define INF 0x3f3f3f3f int min(int a, int b) { return a < b ? a : b; } int main() { static int ww[N][N], dd[N][N][N]; int n, m, q, i, j, k, l; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) memset(ww[i], 0x3f, n * sizeof *ww[i]), ww[i][i] = 0; while (m--) { int w; scanf("%d%d%d", &i, &j, &w), i--, j--; ww[i][j] = min(ww[i][j], w); } for (i = 0; i < n; i++) memset(dd[0][i], 0x3f, n * sizeof *dd[0][i]), dd[0][i][i] = 0; for (l = 0; l < n; l++) { for (i = 0; i < n; i++) for (j = 0; j < n; j++) dd[l + 1][i][j] = INF; for (i = 0; i < n; i++) for (j = 0; j < n; j++) for (k = 0; k < n; k++) dd[l + 1][i][k] = min(dd[l + 1][i][k], dd[l][i][j] + ww[j][k]); } scanf("%d%d", &l, &q), l = min(l, n - 1); while (q--) { scanf("%d%d", &i, &j), i--, j--; printf("%d\n", dd[l][i][j] == INF ? -1 : dd[l][i][j]); } return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d%d%d", &i, &j, &w), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:33:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d%d", &l, &q), l = min(l, n - 1);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:35:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...