QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#800221#9623. 合成大西瓜wjh111Compile Error//C++98572b2024-12-06 00:31:302024-12-06 00:31:32

Judging History

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

  • [2024-12-06 00:31:32]
  • 评测
  • [2024-12-06 00:31:30]
  • 提交

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);
}

詳細信息

answer.code: In function ‘void dfs(int)’:
answer.code:14:19: error: ‘i’ does not name a type
   14 |         for (auto i : p[x]){
      |                   ^
answer.code:20:10: error: expected ‘;’ before ‘}’ token
   20 |         }
      |          ^
      |          ;
   21 | }
      | ~         
answer.code:21:1: error: expected primary-expression before ‘}’ token
   21 | }
      | ^
answer.code:20:10: error: expected ‘;’ before ‘}’ token
   20 |         }
      |          ^
      |          ;
   21 | }
      | ~         
answer.code:21:1: error: expected primary-expression before ‘}’ token
   21 | }
      | ^
answer.code:20:10: error: expected ‘)’ before ‘}’ token
   20 |         }
      |          ^
      |          )
   21 | }
      | ~         
answer.code:14:13: note: to match this ‘(’
   14 |         for (auto i : p[x]){
      |             ^
answer.code:21:1: error: expected primary-expression before ‘}’ token
   21 | }
      | ^