Submission #886020

# Submission time Handle Problem Language Result Execution time Memory
886020 2023-12-11T11:40:16 Z vjudge1 Airplane (NOI23_airplane) C++17
0 / 100
173 ms 15844 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()

int main(){
	int n, m;
	cin>>n>>m;

	vector<int> v(n);
	vector<vector<int>> g(n);
	for(auto &e:v) cin>>e;
	for(int i=0; i<m; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> ans(n, -1), ans2(n, -1);
	priority_queue<pair<int, int>> pq;
	pq.push({0, 0});
	while(pq.size()){
		auto [t, cur]=pq.top();
		pq.pop();

		if(ans[cur]!=-1) continue;
		t=ans[cur]=-t;

		for(auto ch:g[cur]){
			pq.push({-max(t, v[ch]), ch});
		}
	}

	pq.push({0, n-1});
	while(pq.size()){
		auto [t, cur]=pq.top();
		pq.pop();

		if(ans2[cur]!=-1) continue;
		t=ans2[cur]=-t;

		for(auto ch:g[cur]){
			pq.push({-max(t, v[ch]), ch});
		}
	}

	int res=INT_MAX;
	for(int i=0; i<n; i++){
		res=min(res, max(ans[i], ans2[i])*2);
	}
	cout<<res<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 173 ms 15844 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 173 ms 15844 KB Output isn't correct
3 Halted 0 ms 0 KB -