답안 #841779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
841779 2023-09-02T05:18:28 Z vjudge1 Roadside Advertisements (NOI17_roadsideadverts) C++17
컴파일 오류
0 ms 0 KB
/*#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")*/
#include <bits/stdc++.h>
using namespace std;
#define ll int
map<pair<ll,ll>,ll>mp;
map<ll,ll>pm;
ll m[50010];
ll n,cnt,a1,a2,a3,a4,a5;
ll used[50010];
vector<ll>g[50010];
ll tek=0;
void dfs(ll v,ll p)
{
	if(m[v]==1)
	{
		pm[v]=1;
	}
	used[v]=tek;
	for(int it:g[v])
	{
		if(used[it]!=tek)
		{
			dfs(it,v);
		}
	}
	if(pm[v]==1)
	{
		cnt+=mp[{p,v}];
		pm[p]=max(pm[p],1);
		pm[v]=2;
	}
}
void anomalous_solve()
{
    cin>>n;
    ll q,u,v,c;
    for(int i=1;i<n;i++)
    {
    	//cin>>u>>v>>c;
    	scanf("%d%d%d%d%d",&u,&v,&c,);
    	g[u].push_back(v);
    	g[v].push_back(u);
    	mp[{u,v}]=c;
    	mp[{v,u}]=c;
	}
	cin>>q;
	if(q>1000)
	{
		exit(0);
	}
	while(q--)
	{
		tek++;
		scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5);
		//cin>>a1>>a2>>a3>>a4>>a5;
		m[a2]=m[a3]=m[a4]=m[a5]=1;
		dfs(a1,-1);
		cout<<cnt<<"\n";
		
		m[a2]=m[a3]=m[a4]=m[a5]=0;
		cnt=0;
		pm.clear();
	}
}
int main()
{
	//	freopen("INPUT.txt","r",stdin);
	//  freopen("OUTPUT.txt","w",stdout);

	ios_base::sync_with_stdio();
    cin.tie(NULL);
    cout.tie(NULL);

    ll test=1;
	//cin>>test;
    for(int pos=1;pos<=test;pos++)
    	anomalous_solve();
}

Compilation message

roadsideadverts.cpp: In function 'void anomalous_solve()':
roadsideadverts.cpp:42:34: error: expected primary-expression before ')' token
   42 |      scanf("%d%d%d%d%d",&u,&v,&c,);
      |                                  ^
roadsideadverts.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |   scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~