UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#213614#573. t2ckliangCompile Error//C++979b2024-11-12 21:51:462024-11-12 23:57:04

answer

#include<bits/stdc++.h>

using namespace std;
const int N=1e5+100,maxn=1e5+1;
vector<pair<int,int> >G[N];
map<int,int> t[N][2];
int n,q;
void dfs(int u,int f)
{
	int v,w;
	for( auto e:G[u] )
	{
		v=e.first;
		w=e.second;
		if( v==f )continue;
		dfs(v,u);
		for( int i=1 ; i<maxn ; i++ )
		{
			t[u][1][i]+=t[v][1][i]+t[v][0][i];
			if( w%i==0 )
			{
				t[u][1][i]+=t[u][0][i]*(t[v][0][i]+1);
				t[u][0][i]+=t[v][0][i]+1;
			//	cout<<u<<" "<<v<<" "<<i<<endl;
			//	cout<<t[u][1][i]<<" "<<t[u][0][i]<<" "<<t[v][1][i]<<" "<<t[v][0][i]<<endl<<endl;
			}
		//	else t[u][1][i]+=t[v][0][i];
		}
	}
}
int main()
{
	cin>>n>>q;
	int u,v,w;
	for( int i=1 ; i<n ; i++ )
	{
		cin>>u>>v>>w;
		G[u].push_back(make_pair(v,w));
		G[v].push_back(make_pair(u,w));
	}
	dfs(1,0);
	while(q--)
	{
		cin>>u;
	//	cout<<t[1][1][u]<<" "<<t[1][0][u]<<endl; 
		cout<<t[1][1][u]+t[1][0][u]<<endl; 
	}
	return 0;
} 
/*
4 3
1 2 4
2 3 4
2 4 3
4
1
2
*/

Details

answer.code: In function 'void dfs(int, int)':
answer.code:11:12: error: 'e' does not name a type
  for( auto e:G[u] )\x0d
            ^
answer.code:30:1: error: expected ';' before '}' token
 }\x0d
 ^
answer.code:30:1: error: expected primary-expression before '}' token
answer.code:30:1: error: expected ';' before '}' token
answer.code:30:1: error: expected primary-expression before '}' token
answer.code:30:1: error: expected ')' before '}' token
answer.code:30:1: error: expected primary-expression b...