Solution for p2 k=3
DP[i] =dp[i-1]+2*dp2[i-2]+dp[i-3]
Dp2[i]=dp3[i-1]+dp2[i-3]
dp3[i]=dp3[i-3]+dp[i-3]
answer is dp[n]
dp2[i] is the number of ways of to tile a 3i grid with one corner removed and dp3[i] is the number of ways to tile a 3i grid with the rightmost cell removed from first and second row
INOI 2020 was far easier than last year!I think the cutoff is going to be 200 for class 12! But sadly enough my computer hanged today and I spotted the constraint 1<=k<=3, 20 mins after wasting time on a 2D dp solution involving dp[][]! Hence I endend up getting only 132!! I should have attempted the tiling problem first!
Apparently for the first question, if you try to make 2 DFS calls for each component of the graph - 1 to determine which node will serve as the root and 1 to calculate strength of that component with respect to this node, the program gives you a TLE in 2 cases of subtask 2.
My approach was to run DFS on the graph to seperate its connected components out. Then, on each connected component run a DFS to determine its strength.
strength_even = strength of even sized connected components
strength_odd = strength of odd sized connected components
Print strength_even and strength_odd
This gave AC(100 pts) on pretests. Hope it passes system tests.