Forgot Password ?
New password will be sent to following email id
Chotu And Links
Problem Code : LINKS
2 3 1 2 1 1 2 1 3 0 3 1 2 3 1 2 1 3 0
2 2 1 3 2 1
Time Limit :
C , C++ , Java , Python 2
Login to submit your response.
<img src="http://seopressor.com/wp-content/uploads/2016/04/how-crawler-works.png"/> <br> Chotu team are crazy about programming and they want their juniors to be crazy about programming too. So they are training their juniors for ACM-ICPC and gave them <b>T</b> assignments where each assignment has links to <b>N</b> different problems. Each link has a problem of type <b>'X'</b> (dp or strings or whatever) and each link may point to several other links which may or may not contain the problem of same type. <br><br> One of their juniors is writing a web crawler which takes as an input a single link and scrapes the problem in the link and appends it to output. Also it does this recursively for each of the links which is present in the given link. The junior is wondering if <b>i<sup>th</sup></b> link is given as input to the program how many different kind of problems will he have in the output. He is busy participating in <b>24 Hrs of Code</b> on CodeBuddy. Can you help him in this task ? <br> <br>
First line contains number <b>T</b> the number of assignments <br> Each assignment description is as below <br> 1<sup>st</sup> line contains number <b>N</b> the number of links <br> Next line contains <b>N</b> numbers where <b>i<sup>th</sup></b> is the type of problem in <b>i<sup>th</sup></b> link. Each number in this line doesn't exceed 30, i.e. there are at most 31(0-30) different kind of problems. <br> Next <b>N</b> lines contain a number <b>M</b> followed by <b>M</b> numbers which says that <b>i<sup>th</sup></b> link points to these <b>M</b> links and each of the link will be a valid link, i.e. its value will lie in between 1 and <b>N</b> both inclusive. <br> <br>
Should contain <b>N</b> lines each line should say the number of different kind of problems he will get when <b>i<sup>th</sup></b> link is given as input to the crawler.
<br> 1 ≤ <b>T</b> ≤ 20 <br> 1 ≤ <b>N</b> ≤ 200000 <br> If number of links present in <b>i<sup>th</sup></b> link is <b>x_i</b>, then 0 ≤ <b>x_1 + x_2 + x_3 + ... + x_N</b> ≤ 200000 <br>