Descriptioninputoutput for each set of data, if the minimum degree of uncoordinated does not exceed 1018, then the first row of one number indicates that the uncoordinated degree is greater than 1018, the output is "Too hard to arrange" (without quotation marks). After each output, add "--------------------" to the Sample Input4
4 9 3
BRYSJ,
Hhrhl.
YQQLM,
Gsycl.
4 9 2
BRYSJ,
Hhrhl.
YQQLM,
Gsycl.
1 1005 6
Poet
1 1004 6
Poet
Sample Output108
--------------------
32
--------------------
Too Hard to arrange
--------------------
1000000000000000000
--------------------
"Sample description"
The actual length of each row in the first two sets of input data is 6, and the actual length of each row of the last two sets of input data is 4. A space between two sentences per line in a typographic scheme is also counted in the length of the line (see the second set of data in the sample). There are no spaces at the end of each line.
HINT
A total of 10 test points, the data range to meet:
Test point TNLP
1≤10≤18≤100≤5
2≤10≤2000≤60000≤10
3≤10≤2000≤60000≤10
4≤5≤100000≤200≤10
5≤5≤100000≤200≤10
6≤5≤100000≤30000002
7≤5≤100000≤30000002
8≤5≤100000≤3000000≤10
9≤5≤100000≤3000000≤10
10≤5≤100000≤3000000≤10
All test points meet the sentence length of not more than 30.
The following Ttps://www.byvoid.com/blog/noi-2009-poet I only put the AC code
1#include <cstdio>2#include <cstring>3 #definell long double4 structnode{intL,r,p;} q[100100];5 #defineMAX 1000000000000000000LL6 #defineN 1001007 ll Sum[n],f[n];8 intn,l,p,t;9 Charch[ *];Ten ll Pow (ll y) { One if(y<0) y=-y; All ans=1; - for(intI=1; i<=p;i++) ans*=y; - returnans; the } - -LL Calc (intXinty) { - returnF[x]+pow (sum[y]-sum[x]+ (y-x-1)-l); + } - + intFind (Node T,intx) { A intL=t.l,r=T.R; at while(l<=R) { - intMid= (l+r) >>1; - if(Calc (x,mid) <=calc (t.p,mid)) r=mid-1; - ElseL=mid+1; - } - returnl; in } - to voiddp () { + intHead=1, tail=0; -Q[++tail]= (node) {0N0}; the for(intI=1; i<=n;i++){ * if(Q[head].r<i&&head<=tail) head++; $f[i]=Calc (q[head].p,i);Panax Notoginseng if(head>tail| | Calc (i,n) <=Calc (q[tail].p,n)) { - while(Head<=tail&&calc (Q[TAIL].P,Q[TAIL].L) >=calc (I,Q[TAIL].L)) tail--; the if(Head>tail) q[++tail]=(node) {i,n,i}; + Else{ A intx=find (q[tail],i); theq[tail].r=x-1; +q[++tail]=(node) {x,n,i}; - } $ } $ } - } - the intMain () { -scanf"%d",&T);Wuyi while(t--){ thescanf"%d%d%d",&n,&l,&p); - for(intI=1; i<=n;i++) scanf ("%s", ch), sum[i]=sum[i-1]+strlen (CH); Wu DP (); - if(f[n]>MAX) AboutPuts"Too Hard to arrange"); $ Else -printf"%lld\n",(Long Long) f[n]); -Puts"--------------------"); - } A}
"Bzoj 1563" [NOI2009] Poet Small g