UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#213588#573. t2LazyCatCompile Error//C++927b2024-11-12 21:19:472024-11-12 23:51:47

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
bool back=false;
int n,q,ans;
vector<pair<int,int> >e[maxn];
queue<pair<int,int> > p;
void dfs(int d){
	while(!p.empty()){
		pair<int,int> now=p.front();
		p.pop();
		bool end=true;
		for(auto i:e[now.first]){
			if(!(e[now.first].second%d)){
				if(back){
					back=false;
					ans-=now.second*(now.second-1);
				}
				end=false;
				p.push(make_pair(e[now.first].first,now.second+1));
			}
		}
		if(end){
			back=true;
			ans+=now.second*(now.second-1);
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> n >> q;
	for(int i=1;i<=n;i++){
		int u,v,w;
		cin >> u >> v >> w;
		e[u].push_back(make_pair(v,w));
		e[v].push_back(make_pair(u,w));
	}
	int d;
	ans=0;
	while(q--){
		cin >> d;
		p.push(make_pair(1,0));
		dfs(d);
		cout<<ans<<endl;
		back=false;
		ans=0;
	}
	return 0;
} 

Details

answer.code: In function 'void dfs(int)':
answer.code:13:12: error: 'i' does not name a type
   for(auto i:e[now.first]){\x0d
            ^
answer.code:23:3: error: expected ';' before 'if'
   if(end){\x0d
   ^
answer.code:23:3: error: expected primary-expression before 'if'
answer.code:23:3: error: expected ';' before 'if'
answer.code:23:3: error: expected primary-expression before 'if'
answer.code:23:3: error: expected ')' before 'if'