Submission #1055717

# Submission time Handle Problem Language Result Execution time Memory
1055717 2024-08-13T04:25:19 Z 이온조(#11108) Treasure Hunt (CCO24_day1problem1) C++17
25 / 25
896 ms 94560 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;

ll D[1000009];
vector<pii> G[1000009];

int main() {
	int N, M; scanf("%d%d", &N, &M);
	priority_queue<pli> pq;
	for(int i=1; i<=N; i++) {
		scanf("%lld", &D[i]);
		pq.push({D[i], i});
		D[i] = -D[i];
	}
	for(int i=0; i<M; i++) {
		int u, v, c; scanf("%d%d%d", &u, &v, &c);
		G[u].push_back({v, c});
		G[v].push_back({u, c});
	}
	while(pq.size()) {
		auto [d, x] = pq.top(); pq.pop(); d = -d;
		if(D[x] != d) continue;
		for(auto [it, c]: G[x]) if(D[it] > d + c) {
			D[it] = d + c;
			pq.push({-D[it], it});
		}
	}
	for(int i=1; i<=N; i++) printf("%lld\n", -D[i]);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:11:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  int N, M; scanf("%d%d", &N, &M);
      |            ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%lld", &D[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:19:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   int u, v, c; scanf("%d%d%d", &u, &v, &c);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 25432 KB Output is correct
2 Correct 5 ms 25436 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 3 ms 25180 KB Output is correct
6 Correct 3 ms 25180 KB Output is correct
7 Correct 3 ms 25180 KB Output is correct
8 Correct 5 ms 25180 KB Output is correct
9 Correct 4 ms 25436 KB Output is correct
10 Correct 5 ms 25200 KB Output is correct
11 Correct 3 ms 25180 KB Output is correct
12 Correct 5 ms 25180 KB Output is correct
13 Correct 3 ms 25180 KB Output is correct
14 Correct 3 ms 25180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 891 ms 93820 KB Output is correct
2 Correct 793 ms 93708 KB Output is correct
3 Correct 856 ms 93712 KB Output is correct
4 Correct 787 ms 93764 KB Output is correct
5 Correct 782 ms 92836 KB Output is correct
6 Correct 834 ms 92672 KB Output is correct
7 Correct 751 ms 91560 KB Output is correct
8 Correct 769 ms 90024 KB Output is correct
9 Correct 677 ms 88032 KB Output is correct
10 Correct 706 ms 87208 KB Output is correct
11 Correct 627 ms 82852 KB Output is correct
12 Correct 634 ms 82088 KB Output is correct
13 Correct 580 ms 78628 KB Output is correct
14 Correct 579 ms 78992 KB Output is correct
15 Correct 273 ms 56768 KB Output is correct
16 Correct 247 ms 57460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 835 ms 94232 KB Output is correct
2 Correct 878 ms 93864 KB Output is correct
3 Correct 861 ms 93864 KB Output is correct
4 Correct 845 ms 93820 KB Output is correct
5 Correct 3 ms 25176 KB Output is correct
6 Correct 3 ms 25180 KB Output is correct
7 Correct 896 ms 94480 KB Output is correct
8 Correct 864 ms 94116 KB Output is correct
9 Correct 809 ms 93864 KB Output is correct
10 Correct 831 ms 93880 KB Output is correct
11 Correct 4 ms 25180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 25432 KB Output is correct
2 Correct 5 ms 25436 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 3 ms 25180 KB Output is correct
6 Correct 3 ms 25180 KB Output is correct
7 Correct 3 ms 25180 KB Output is correct
8 Correct 5 ms 25180 KB Output is correct
9 Correct 4 ms 25436 KB Output is correct
10 Correct 5 ms 25200 KB Output is correct
11 Correct 3 ms 25180 KB Output is correct
12 Correct 5 ms 25180 KB Output is correct
13 Correct 3 ms 25180 KB Output is correct
14 Correct 3 ms 25180 KB Output is correct
15 Correct 891 ms 93820 KB Output is correct
16 Correct 793 ms 93708 KB Output is correct
17 Correct 856 ms 93712 KB Output is correct
18 Correct 787 ms 93764 KB Output is correct
19 Correct 782 ms 92836 KB Output is correct
20 Correct 834 ms 92672 KB Output is correct
21 Correct 751 ms 91560 KB Output is correct
22 Correct 769 ms 90024 KB Output is correct
23 Correct 677 ms 88032 KB Output is correct
24 Correct 706 ms 87208 KB Output is correct
25 Correct 627 ms 82852 KB Output is correct
26 Correct 634 ms 82088 KB Output is correct
27 Correct 580 ms 78628 KB Output is correct
28 Correct 579 ms 78992 KB Output is correct
29 Correct 273 ms 56768 KB Output is correct
30 Correct 247 ms 57460 KB Output is correct
31 Correct 835 ms 94232 KB Output is correct
32 Correct 878 ms 93864 KB Output is correct
33 Correct 861 ms 93864 KB Output is correct
34 Correct 845 ms 93820 KB Output is correct
35 Correct 3 ms 25176 KB Output is correct
36 Correct 3 ms 25180 KB Output is correct
37 Correct 896 ms 94480 KB Output is correct
38 Correct 864 ms 94116 KB Output is correct
39 Correct 809 ms 93864 KB Output is correct
40 Correct 831 ms 93880 KB Output is correct
41 Correct 4 ms 25180 KB Output is correct
42 Correct 885 ms 94136 KB Output is correct
43 Correct 844 ms 93864 KB Output is correct
44 Correct 858 ms 93752 KB Output is correct
45 Correct 833 ms 93856 KB Output is correct
46 Correct 818 ms 94372 KB Output is correct
47 Correct 826 ms 92488 KB Output is correct
48 Correct 834 ms 92944 KB Output is correct
49 Correct 720 ms 89512 KB Output is correct
50 Correct 802 ms 90936 KB Output is correct
51 Correct 271 ms 60856 KB Output is correct
52 Correct 299 ms 62224 KB Output is correct
53 Correct 165 ms 50516 KB Output is correct
54 Correct 158 ms 50520 KB Output is correct
55 Correct 877 ms 93872 KB Output is correct
56 Correct 858 ms 94560 KB Output is correct
57 Correct 328 ms 78760 KB Output is correct