Help - Code error

I am getting compilation error and i don’t know the reason . I’ve tried about 1 hour and i’m unable to find it please help :slight_smile:

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[100001];
vector<int>visited(100001,0);
void dfs(int node,int &c)
{
	if(visited[node]==0){
		c++;
		visited[node]=1;
	}
	for(int i = 0 ; i < adj[node].size() ; i++){
		if(!visited[adj[node][i]]){
			dfs(adj[node][i],c);
		}
	}	
}
int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n,a,b,weight;
		cin >> n;
		vector<pair<int,int>,int>edges;
		for(int i = 0 ;i < n-1 ; i++ ){
			cin >> a >> b >> weight;
			edges.push_back(make_pair(make_pair(a,b),weight));
			adj[a].push_back(b);
			adj[b].push_back(a);
		}
		int ans = 0,c1=0,c2=0;
		for(int i = 0 ; i < n-1 ; i++ )
		{
			visited.clear();
			dfs(edges[i].first.first,c1,visited);
			visited.clear();
			dfs(edges[i].first.second,c2,visited);
			ans += min(c1,c2)*2*(edges[i].second);
			c1 = 0;
			c2 = 0;
		}
		cout<<ans<<'\n';
	}
}

I am getting this error

This line makes no sense:

vector<pair<int,int>,int>edges;

What’s it supposed to be?

Edit:

Looking at later code, did you mean:

vector<pair<pair<int,int>,int>>edges;

?

2 Likes

@ssjgz Okaaaaaaaaaaayy ! Got it ! Got it !:zipper_mouth_face:

1 Like