You are viewing a single comment's thread. Return to all comments →
cbuff's link and dingma129's post is really helpful, thnx^^ but if u need code:
int gr[501]; int dfs(int u, int p, vector<vector<int>>& G){ for(auto ch : G[u]){ if(ch != p) gr[u] ^= dfs(ch,u,G); } return u == 1 ? gr[u] : ++gr[u]; } string deforestation(int n, vector<vector<int>> tree) { memset(gr, 0, sizeof(gr)); vector<vector<int>> G(n+1); for(auto p : tree){ G[p[0]].push_back(p[1]); G[p[1]].push_back(p[0]); } return dfs(1,-1,G) ? "Alice" : "Bob"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Deforestation
You are viewing a single comment's thread. Return to all comments →
cbuff's link and dingma129's post is really helpful, thnx^^ but if u need code: