chiedo un aiuto perché ottengo 0
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <list>
using namespace std;
#define MAXN 1000
vector <int> G[MAXN]; // GRAFO
stack <int> pila;
int B[MAXN]={0}, C[MAXN]={0};
int N;
int dfs(int nodo)
{ int S1=0; int S2=0;
pila.push(nodo);
while (!pila.empty())
{ S1=pila.top();
pila.pop();
S1=B[nodo];
if (B[nodo]==false)
{ B[nodo]=true;
for(int i=0;i<G[nodo].size();i++)
{ S2+=dfs(G[nodo][i]);
pila.push(i); }}
return max(S1,S2); } }
int main(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
cin>>N; int B[N], C[N];
for (int i=0; i<N; i++)
cin>>B[i]>>C[i];
cout<<dfs(0);
return 0;
}