This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#define N 40
#define K 1000
#define M ((N + K) * 2)
int main() {
static int dd[N + 1], dd_[N + 1], ii[M], jj[M], ww[M];
static char cc[N + 1];
int n, k, m, h, i, j, w, d;
scanf("%d%d", &n, &k);
m = 0;
for (i = 0; i < n; i++) {
ii[m] = i, jj[m] = i + 1, ww[m] = 1, m++;
ii[m] = i + 1, jj[m] = i, ww[m] = 0, m++;
}
while (k--) {
scanf("%d%d%d", &i, &j, &w), i--;
ii[m] = i, jj[m] = j, ww[m] = w, m++;
ii[m] = j, jj[m] = i, ww[m] = -w, m++;
}
for (k = 0; k <= n + 1; k++) {
memcpy(dd_, dd, (n + 1) * sizeof *dd);
for (h = 0; h < m; h++) {
i = ii[h], j = jj[h], w = ww[h], d = dd[i] + w;
if (dd[j] > d) {
dd[j] = d;
if (k == n) {
printf("NONE\n");
return 0;
}
}
}
}
for (i = 0; i < n; i++)
cc[i] = dd[i + 1] == dd[i] ? '-' : '#';
printf("%s\n", cc);
return 0;
}
Compilation message (stderr)
probe.c: In function 'main':
probe.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d%d", &n, &k);
| ^~~~~~~~~~~~~~~~~~~~~
probe.c:20:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d%d%d", &i, &j, &w), i--;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |