Ensure that you are logged in and have the required permissions to access the test.

Whimsical Happening

0

0 votes
Medium
Problem

“I’m not a psychopath, Anderson. I’m a high-functioning sociopath. Do your research.” -Sherlock

Problem 4:

Given the start and the finish time of visiting all the vertex in the tree. You need to output the cardinality of all the vertex.

time=0
void dfs(int s)
{
    start[s]=++time
    visit[s]=true
    for each x adjacent to s:
        if visit[x] :
            continue
        dfs(x)
    end[s]=time 
}
Note : cardinality of a vertex is the total number of edges which are connected to it.

Input:

First line of the input contains T representing the number of test cases in the input.

First line of each test case contains a single integer n representing the total number of vertex in the tree.

Second line contains n space separated integers denoting the start time of the jth vertex;

Third line contains n space separated integers denoting the finish time of the jth vertex.

Output:

Output is of single line representing space separated integers on a single line corresponding to every vertex. For more clarity see the sample.

Constraints :

1T10

1n105

1s[j]f[j]n

here s[j] and f[j] are the start and finish time of the jth vertex.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?