Submission #944492

# Submission time Handle Problem Language Result Execution time Memory
944492 2024-03-12T19:08:39 Z rainboy 탐사 (KOI13_probe) C
19 / 19
1 ms 428 KB
#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

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
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 424 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct