Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. freopen("warcraft.in", "r", stdin);
  2. freopen("warcraft.out", "w", stdout);
  3. int nr, a, b, k, n2, scount, nrcc(0);
  4. scanf("%d%d%d", &n, &m, &x);
  5.  
  6. for(int i = 1; i <= n; i++) {
  7. scanf("%d%d%d", &a, &b, &k);
  8. parent[a] = b;
  9.  
  10. if(b != 0) {
  11. g[a].push_back(b);
  12. g[b].push_back(a);
  13. } else capetenie[a] = true; // atentie aici
  14. for(int j = 1; j <= k; j++) {
  15. scanf("%d", &nr);
  16. powers[a].push_back(nr);
  17. }
  18. }
  19.  
  20. for(int i = 1; i <= n; i++) {
  21. if(!visited[i] && capetenie[i]) { // si aici
  22. is_ok = false;
  23. nrcc++;
  24. scount = 0;
  25.  
  26. c[nrcc].warchief = i;
  27.  
  28. DFS(i, scount, nrcc);
  29. // in rest am cealalta cerinta
  30. // ce spun e ca nu trebuie sa faci dfs din toate nodurile nevizitate, ci doar din capetenii
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement