Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- #define Nmax 100001
- using namespace std;
- vector<int> G[Nmax];
- vector<bool> scandalagiu;
- vector<bool> viz;
- int n,k,nr;
- void df(int nod)
- {
- viz[nod]=1;
- for(auto v:G[nod])
- if(!scandalagiu[v]&&!viz[v])
- df(v),++nr;
- }
- int main()
- {
- ifstream f("protest.in");
- f>>n>>k;
- scandalagiu=vector<bool>(n+1);
- viz=vector<bool>(n+1);
- for(int i=1,sc;i<=k;++i)
- f>>sc,scandalagiu[sc]=1;
- int x,y;
- while(--n)
- f>>x>>y,G[x].push_back(y);
- f.close();
- df(1);
- ofstream g("protest.out");
- g<<nr;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement