I can't think of it at all.
It turned out to be a violent miracle, Qaq.
Infinity in YMYMYM
1 /**************************************************************2 problem:40073 User:rausen4 language:c++5 result:accepted6 time:240 Ms7 memory:13216 KB8 ****************************************************************/9 Ten#include <cstdio> One#include <cstring> A#include <algorithm> - - using namespacestd; the Const intN = (1<<Ten) +5; - - intN, m, ans; - intA[n][n], b[n][n], f[n][n]; + intNow[n]; - +Inlineintread (); A at #defineLS P << 1 - #defineRS P << 1 | 1 - voidDfsintPintSZ) { - intI, J, MNL, MXL, tot; - if(SZ = =1) { -f[p][0] = f[p][1] =0; in for(i = P >>1; I I >>=1) - if(Now[i] = =0) f[p][1] +=A[p][i]; to Elsef[p][0] +=B[p][i]; + return; - } thetot =min (sz, m); *memset (F[p],0,sizeof(f[0][0]) * (Tot +1)); $NOW[P] =0;Panax NotoginsengDFS (LS, sz >>1), DFS (RS, sz >>1); - for(i =0; I <= tot; ++i) { theMNL = max (i-(SZ >>1),0), MXL = min (sz >>1, i); + for(j = mnl; J <= Mxl; + +)j) AF[p][i] = max (F[p][i], f[ls][j] + f[rs][i-j]); the } + -NOW[P] =1; $DFS (LS, sz >>1), DFS (RS, sz >>1); $ for(i =0; I <= tot; ++i) { -MNL = max (i-(SZ >>1),0), MXL = min (sz >>1, i); - for(j = mnl; J <= Mxl; + +)j) theF[p][i] = max (F[p][i], f[ls][j] + f[rs][i-j]); - } Wuyi } the #undefLs - #undefRs Wu - intMain () { About intI, J; $n = Read (), M =read (); - for(i =1<< N-1; I <1<< N; ++i) - for(j = i >>1; J J >>=1) -A[I][J] =read (); A for(i =1<< N-1; I <1<< N; ++i) + for(j = i >>1; J J >>=1) theB[I][J] =read (); -Dfs1,1<< N-1); $ for(ans = i =0; I <= m; ++i) theans = max (ans, f[1][i]); theprintf"%d\n", ans); the return 0; the } - inInlineintRead () { the Static intx; the Static Charch; Aboutx =0, ch =GetChar (); the while(Ch <'0'||'9'<ch) theCH =GetChar (); the while('0'<= CH && Ch <='9') { +x = x *Ten+ CH-'0'; -CH =GetChar (); the }Bayi returnx; the}View Code
BZOJ4007 [JLOI2015] War Dispatch