3140: [Hnoi2013] DisinfectionDescription
Little T, who recently worked in a biology lab, is in big trouble.
Due to the recent upgrade of the laboratory, his sub-test dish is a cuboid with a size of A*b*c,a, B, and C as positive integers. For the convenience of the experiment, it is divided into a*b*c units of cube area, each unit cube size
For 1*1*1. Use (i,j,k) to identify a unit cube, 1≤i≤a,1≤j≤b,1≤k≤c. The experiment dish has been out of use for a long time, and now little T is being asked by the tutor to sterilize some of the units in the cube area (each area can be disinfected repeatedly). As a result of rigorous experimental requirements, he was asked to use a specific F-reagent for disinfection. This f reagent is particularly strange, and each time a box area of size x*y*z (which consists of a x*y*z unit cube) is disinfected, only the F reagent of min{x,y,z} units is required. The price of the F-reagent is expensive, which can overwhelm the small T. Now please tell him how many units of F reagent to use at least. (Note: Min{x,y,z} represents the smallest person in x, Y, Z.) )
InputThe first line is a positive integer d, which represents the number of data groups. Next is the D group of data, each set of data starting with three numbers a,b,c indicates the size of the experiment dish. Next there will be a B row C column space-separated 01 matrix, 0 indicates that the corresponding unit cube does not require disinfection, 1 indicates that the corresponding unit cube needs disinfection; For example, if the 2nd row 3rd of the 1th 01 matrix is 1, the unit cube (three-to-one) needs to be disinfected. The input is guaranteed to meet a*b*c≤5000,t≤3. Output
Contains only d lines, an integer per line, indicating the minimum number of units of F reagent to be used for the corresponding experiment dish.
Sample Input1
4 4 4
1 0 1 1
0 0 1 1
0 0 0 0
0 0 0 0
0 0 1 1
1 0 1 1
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
Sample Output3HINT
For areas (1,1,3)-(2,2,4) and (1,1,1)-(4,4,1) disinfection, respectively, cost 2 units and 1 units of F reagent.
Acty!!!
—————— ——————
The problem is still quite similar to the board coverage, X*y*z area (x<y<z), which is equivalent to X 1*y*z area.
But even the side of the word is not to be a three-figure matching it??!!!
Some people may make the whole picture into two dimensions (that is, ignoring the high), but the answer is wrong.
Well, notice the x*y*z<=5000, the X into the smallest side, then the x<=17, then the direct burst search, select some of the surface directly thrown away, the number of times plus 1, the remaining synthetic two-dimensional graph run the maximum match.
#include <stdio.h>#include<iostream>#include<algorithm>using namespacestd;Const intn=5005;structnode{intA,b,c;} P[n];intt,num,tot,ans,a,b,c,i,j,k,i,j,k,x,p[n],f[n],h[ -];inthead[n],next[n<<1],to[n<<1];voidSWAP (int&i,int&j,int&k) { if(a>b) Swap (I,J); if(a>c) Swap (I,K); if(b>c) Swap (j,k);}voidAddintXinty) {Tot++; To[tot]=y; Next[tot]=Head[x]; HEAD[X]=tot;}intDfsintXintM) { for(inti=head[x];i!=-1; i=Next[i]) { inty=To[i]; if(p[y]==m)Continue; P[y]=M; if(f[y]==0||DFS (F[Y],M)) {F[y]=x; return 1; } } return 0;}voidDfs (intXintCNT) { if(Cnt>=ans)return; if(x>a) {inti; Tot=0; for(i=1; i<=c;i++) Head[i]=-1, f[i]=p[i]=0; for(i=1; i<=num;i++) if(h[p[i].a]==0) Add (P[I].B,P[I].C); for(i=1; i<=b;i++) {CNT+=DFS (i,i); if(Cnt>=ans)return; } ans=CNT; } H[x]=1; DFS (x+1, cnt+1); H[X]=0; DFS (x+1, CNT);}intMain () {scanf ("%d",&T); while(t--) {scanf ("%d%d%d",&a,&b,&c); Num=0; for(i=1; i<=a;i++) for(j=1; j<=b;j++) for(k=1; k<=c;k++) {scanf ("%d",&x); if(x) {I=i; J=j; k=K; SWAP (I,J,K); Num++; P[NUM].A=i; P[num].b=j; P[num].c=J; }} SWAP (A,b,c); Ans=A; Dfs (1,0); printf ("%d\n", ans); } return 0;}
Bzoj 3140: [Hnoi2013] Disinfection