"2019.8.9 exam" dp people to the gods know what to do

  T1 is the inclusion-exclusion, I pinched a finger count his card to the correctness of inclusion and exclusion, and will never n m a very similar ($ O (n ^ 2) $ complexity of the algorithm to achieve the highest nm equal time in the time ), or to do good, then he opened the special sentence + various cards often and rolling array optimization, cards to 70 points, $ n ^ 2 $ over 100000, violence grind standard count. T2 thirteen minutes AC nothing to say, it is moderation. Probably a flag up. T3, then took the 50 thought-like pressure, it seems I was too naive. WA 10 points, QJ another 10 minutes did not get noooooooo. In fact, the title is intended to understand there are deviations.

 

T1 like a long time did not think the number of combinations, T2 directly seconds off, T3 fought for a long waste, probably this is your fate, the next goal is to swap T1 A, (A've never had so many games T1 ..)

 

Here is the problem solution:

T1: Consider vigorously inclusion and exclusion, on the test have been thinking about how to dig up a one-dimensional dp eventually found not to dig, directly over, did not want to inclusion and exclusion, in fact, very good think.

$ans=C_{m-n+n-1}^{n-1}+\sum \limits_{i=1}^{min(n,m/K)}(-1)^iC_{m-n+(n-1)-iK}^{n-1}C_n^i$

$ans=C_{m-1}^{n-1}+\sum \limits_{i=1}^{min(n,m,K)}(-1)^iC_{m-1-iK}^{n-1}C_n^i$

O (m) both inclusion and exclusion.

 

T2: old routines built anti FIG Tarjan condensing point + dp + topology can.

DP provided $ [i] is the i th $ SCC completely bombing time required.

$dp[i]=\max \limits_j^{e(i,j)} dp[j]+sz[i]$

$ans=\max \limits_{i=1}^{n} dp[i]$

 

T3 is a fairy dp, is the true god.

Guess you like

Origin www.cnblogs.com/Lrefrain/p/11330377.html