Submission #828282

# Submission time Handle Problem Language Result Execution time Memory
828282 2023-08-17T07:40:21 Z 반딧불(#10380) Airplane (NOI23_airplane) C++17
100 / 100
507 ms 39416 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct dat{
	int x; ll dist; /// dist: 실제 시간, off: arr[i] 값에 비해 초과된 시간
	dat(){}
	dat(int x, ll dist): x(x), dist(dist){}

	bool operator<(const dat &r)const{
		return dist > r.dist;
	}
};

int n, m, s, e;
vector<int> link[400002];
int ex[400002], ey[400002];
ll arr[400002];
ll dists[400002]; bool visiteds[400002];
ll diste[400002]; bool visitede[400002];
priority_queue<dat> pq;
ll ans = LLONG_MAX;

int main(){
	scanf("%d %d", &n, &m);
	s = 1, e = n;
	for(int i=1; i<=n; i++) scanf("%lld", &arr[i]), arr[i] *= 2;
	for(int i=1; i<=m; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		ex[i] = x, ey[i] = y;
		link[x].push_back(y), link[y].push_back(x);
	}

	pq.push(dat(s, 0));
	while(!pq.empty()){
		dat tmp = pq.top(); pq.pop();
		if(visiteds[tmp.x]) continue;
		visiteds[tmp.x] = 1, dists[tmp.x] = tmp.dist;
		for(auto y: link[tmp.x]){
			pq.push(dat(y, max(tmp.dist+2, arr[y])));
		}
	}

	pq.push(dat(e, 0));
	while(!pq.empty()){
		dat tmp = pq.top(); pq.pop();
		if(visitede[tmp.x]) continue;
		visitede[tmp.x] = 1, diste[tmp.x] = tmp.dist;
		for(auto y: link[tmp.x]){
			pq.push(dat(y, max(tmp.dist+2, arr[y])));
		}
	}

	for(int i=1; i<=n; i++){
		#ifdef TEST
		printf("%d dists: %lld, diste: %lld\n", i, dists[i], diste[i]);
		#endif
		ans = min(ans, max(dists[i], diste[i]));
	}
	for(int i=1; i<=m; i++){
		ans = min(ans, max(dists[ex[i]], diste[ey[i]])+1);
		ans = min(ans, max(diste[ex[i]], dists[ey[i]])+1);
	}
	printf("%lld", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:29:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  for(int i=1; i<=n; i++) scanf("%lld", &arr[i]), arr[i] *= 2;
      |                          ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 77 ms 22568 KB Output is correct
3 Correct 79 ms 22600 KB Output is correct
4 Correct 78 ms 22556 KB Output is correct
5 Correct 85 ms 22620 KB Output is correct
6 Correct 82 ms 22624 KB Output is correct
7 Correct 80 ms 22628 KB Output is correct
8 Correct 4 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 5 ms 9644 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9748 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 6 ms 9816 KB Output is correct
7 Correct 5 ms 9812 KB Output is correct
8 Correct 6 ms 9812 KB Output is correct
9 Correct 6 ms 9760 KB Output is correct
10 Correct 5 ms 9812 KB Output is correct
11 Correct 5 ms 9860 KB Output is correct
12 Correct 5 ms 9812 KB Output is correct
13 Correct 5 ms 9812 KB Output is correct
14 Correct 6 ms 9812 KB Output is correct
15 Correct 6 ms 9940 KB Output is correct
16 Correct 6 ms 9940 KB Output is correct
17 Correct 6 ms 9940 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 5 ms 9644 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9748 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 6 ms 9816 KB Output is correct
7 Correct 5 ms 9812 KB Output is correct
8 Correct 6 ms 9812 KB Output is correct
9 Correct 6 ms 9760 KB Output is correct
10 Correct 5 ms 9812 KB Output is correct
11 Correct 5 ms 9860 KB Output is correct
12 Correct 5 ms 9812 KB Output is correct
13 Correct 5 ms 9812 KB Output is correct
14 Correct 6 ms 9812 KB Output is correct
15 Correct 6 ms 9940 KB Output is correct
16 Correct 6 ms 9940 KB Output is correct
17 Correct 6 ms 9940 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 5 ms 9812 KB Output is correct
20 Correct 6 ms 9844 KB Output is correct
21 Correct 6 ms 9784 KB Output is correct
22 Correct 6 ms 9812 KB Output is correct
23 Correct 6 ms 9812 KB Output is correct
24 Correct 6 ms 9812 KB Output is correct
25 Correct 6 ms 9812 KB Output is correct
26 Correct 6 ms 9812 KB Output is correct
27 Correct 6 ms 9940 KB Output is correct
28 Correct 6 ms 9940 KB Output is correct
29 Correct 6 ms 9944 KB Output is correct
30 Correct 9 ms 9940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 77 ms 22568 KB Output is correct
3 Correct 79 ms 22600 KB Output is correct
4 Correct 78 ms 22556 KB Output is correct
5 Correct 85 ms 22620 KB Output is correct
6 Correct 82 ms 22624 KB Output is correct
7 Correct 80 ms 22628 KB Output is correct
8 Correct 4 ms 9676 KB Output is correct
9 Correct 6 ms 9684 KB Output is correct
10 Correct 5 ms 9644 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9748 KB Output is correct
13 Correct 5 ms 9684 KB Output is correct
14 Correct 6 ms 9816 KB Output is correct
15 Correct 5 ms 9812 KB Output is correct
16 Correct 6 ms 9812 KB Output is correct
17 Correct 6 ms 9760 KB Output is correct
18 Correct 5 ms 9812 KB Output is correct
19 Correct 5 ms 9860 KB Output is correct
20 Correct 5 ms 9812 KB Output is correct
21 Correct 5 ms 9812 KB Output is correct
22 Correct 6 ms 9812 KB Output is correct
23 Correct 6 ms 9940 KB Output is correct
24 Correct 6 ms 9940 KB Output is correct
25 Correct 6 ms 9940 KB Output is correct
26 Correct 5 ms 9684 KB Output is correct
27 Correct 5 ms 9812 KB Output is correct
28 Correct 6 ms 9844 KB Output is correct
29 Correct 6 ms 9784 KB Output is correct
30 Correct 6 ms 9812 KB Output is correct
31 Correct 6 ms 9812 KB Output is correct
32 Correct 6 ms 9812 KB Output is correct
33 Correct 6 ms 9812 KB Output is correct
34 Correct 6 ms 9812 KB Output is correct
35 Correct 6 ms 9940 KB Output is correct
36 Correct 6 ms 9940 KB Output is correct
37 Correct 6 ms 9944 KB Output is correct
38 Correct 9 ms 9940 KB Output is correct
39 Correct 205 ms 22680 KB Output is correct
40 Correct 107 ms 22608 KB Output is correct
41 Correct 115 ms 22560 KB Output is correct
42 Correct 139 ms 22656 KB Output is correct
43 Correct 150 ms 22604 KB Output is correct
44 Correct 142 ms 22680 KB Output is correct
45 Correct 170 ms 22592 KB Output is correct
46 Correct 129 ms 22604 KB Output is correct
47 Correct 163 ms 22688 KB Output is correct
48 Correct 148 ms 22600 KB Output is correct
49 Correct 227 ms 22768 KB Output is correct
50 Correct 159 ms 22688 KB Output is correct
51 Correct 180 ms 22656 KB Output is correct
52 Correct 343 ms 26988 KB Output is correct
53 Correct 308 ms 27020 KB Output is correct
54 Correct 302 ms 26976 KB Output is correct
55 Correct 324 ms 25812 KB Output is correct
56 Correct 452 ms 30500 KB Output is correct
57 Correct 413 ms 29572 KB Output is correct
58 Correct 431 ms 28992 KB Output is correct
59 Correct 507 ms 35752 KB Output is correct
60 Correct 369 ms 39416 KB Output is correct
61 Correct 500 ms 35364 KB Output is correct
62 Correct 364 ms 38364 KB Output is correct
63 Correct 374 ms 38328 KB Output is correct
64 Correct 361 ms 38384 KB Output is correct
65 Correct 377 ms 38412 KB Output is correct
66 Correct 411 ms 35392 KB Output is correct
67 Correct 432 ms 35308 KB Output is correct