Invitation to SpyBits, Udyam'21 - IIT (BHU) Varanasi (Rated for Div. 2 & Div. 3)

Can someone help me with this problem for Problem D Pilgrims?
Here is my solution giving WA https://www.codechef.com/viewsolution/45072902

What i did is, did dfs to calculate cost of all nodes untill all were visited and when a leaf was found, inserted it into answer vector. Finally greedily assigned maximum energies people to maximum cost that was possible for them

What if node 1 has only 1 node attached to it?

where r editorials @adikr_singh

you mean this test case?
1
2 4
190 20 10 50
1 2 10

but here both nodes are leaves and cost(1)=0 and cost(2)=10 so we can assign 2 people right?

Hey , in your last loop calculating the answer, your condition is i <N instead of i<X.size() . Because special cities will be less than n.
Here is corrected solution. (I also made int long long)
https://www.codechef.com/viewsolution/45075152

1 Like

all of them in a few hours

It seems my code is correct for problem D - Click Here
But I am getting WA in it, I have also covered the corner case (didn’t consider 1 as the special city).

I ran a DFS and calculated the distances of the leaf nodes(special cities) and then I greedily assigned the special cities to the people.

Can anyone point out the mistake, where I am going wrong?

When ratings will be updated?

Its mentioned in the question not to take the captial city (node 1) as a special node.

my bad. will this change alone work ? if(adj[v].size()==1 && v!=1)
I submitted but its still in queue

It should. Can’t find any other errors in your code

Never mind, I literally crossed all heights of stupidity be assuming A<B and getting those nasty RTES.

Thank you brother but I don’t get it what difference it makes by taking capital city also. I mean the problem setters purposefully use these kind of wierd and unnecessary condition to penalize or waste time of users. I really don’t find the need of such unnecessary confusions in problem statements as it teaches nothing

Well , you are wrong , It teaches people like me and you to read problem statements carefully , Yeah I also got a few WA because of that condition

3 Likes

The test cases for STONE LAND are really weak
this O(N*Q) solution works

@admin My junior rating graph is not updated although rating is. Will it be updated, can you look into it? Thanks.

Thanks for reporting. We’ll look into it.

Hi, should be fixed now.

1 Like

yes all good now

Thanks man such a silly mistake and I wasn’t able to figure it out.Thanks !!

1 Like