QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#800223#9623. 合成大西瓜wjh111WA 0ms6368kbC++11572b2024-12-06 00:32:112024-12-06 00:32:12

Judging History

你现在查看的是最新测评结果

  • [2024-12-06 00:32:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:6368kb
  • [2024-12-06 00:32:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
vector<int>p[100009];
int ans1=1e9,ans2=-1,v[100009],a[100009];
void dfs(int x){
	if (p[x].size()==1){
		ans1=min(ans1,a[x]);
		if (x!=1)
		return ;
	}
	else{
		ans2=max(ans2,a[x]);
	}
	for (auto i : p[x]){
		if (v[i]){
			continue;
		}
		v[i]=1;
		dfs(i);
	}
}
int main(){
	int n,x,y,m,i;
	cin>>n>>m;
	for (i=0;i<n;i++){
		cin>>a[i+1];
	}
	for (i=0;i<m;i++){
		cin>>x>>y;
		p[x].push_back(y);
		p[y].push_back(x);
	}
	v[1]=1;
	dfs(1);
	//cout<<ans1<<" "<<ans2<<" ";
	cout<<max(ans1,ans2);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6004kb

input:

7 9
1 4 1 3 3 6 7
5 4
3 6
3 4
2 3
5 2
2 6
6 7
5 1
4 6

output:

6

result:

ok single line: '6'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 6368kb

input:

5 7
1 5 3 1 4
3 5
1 3
5 1
1 4
5 4
2 4
3 2

output:

1000000000

result:

wrong answer 1st lines differ - expected: '5', found: '1000000000'