Advertisement
a53

protest

a53
Feb 1st, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <fstream>
  2. #include <vector>
  3. #define Nmax 100001
  4. using namespace std;
  5. vector<int> G[Nmax];
  6. vector<bool> scandalagiu;
  7. vector<bool> viz;
  8. int n,k,nr;
  9.  
  10. void df(int nod)
  11. {
  12. viz[nod]=1;
  13. for(auto v:G[nod])
  14. if(!scandalagiu[v]&&!viz[v])
  15. df(v),++nr;
  16. }
  17.  
  18. int main()
  19. {
  20. ifstream f("protest.in");
  21. f>>n>>k;
  22. scandalagiu=vector<bool>(n+1);
  23. viz=vector<bool>(n+1);
  24. for(int i=1,sc;i<=k;++i)
  25. f>>sc,scandalagiu[sc]=1;
  26. int x,y;
  27. while(--n)
  28. f>>x>>y,G[x].push_back(y);
  29. f.close();
  30. df(1);
  31. ofstream g("protest.out");
  32. g<<nr;
  33. g.close();
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement