Failing Phobia of Jay
All submissions for this problem are available.
Chef Jay have recently qualified for INOI, and he can't keep his excitment with himself and share this news with 'K' of his friends.
One day Scrolling on Instagram Jay find a quote written : "The more the people knows, the more is the chances of FAILURE.", Now reading this he is scared and fears what if it will become true. However, he is well prepared for INOI even though he wants to find the number of peoples who had by now known the news.
Jay knows his friends and his friends friend (and so on) very well, he knows that his friends will share this news to every friend who has friendship strength ≤ 'S'.
You are given the graph representing the friendship and the friendship strength, find the number of peoples who knows this news. The graph can also be disconnected.
- 1st line:
N M (N = No of total friends, M = total no of friendship bonds)
- Next M Lines contains 3 integers.
a,b,c representing a and b are both friends with friendship strength of c.
- A blank line follows
- K S (K = no of friends with whom Jay shared the news, S = mentioned above)
- Next K space separated integers representing the friends whom Jay shared the news.
- Single Integer representing the number of friends who by now knows a news.
- 1≤N≤ 100,000 M≤min(123456, N(N-1)/2), K≤ N, S≤ 109
- 1≤a,b≤N, 1≤c≤109
- Ki ≤ N
- 10 pts: N≤100
- 20 pts: N≤1000
- 70 pts: Original Constaints
1 2 6
1 3 3
2 3 2
3 4 6
3 5 5
|Tags||akashbhalotia, dfs, easy, ico, icop1904, jvjplus|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, kotlin, PYP3, FS|
Fetching successful submissions