3140: [Hnoi2013]消毒
首先要知道一次打掉一个1*x*y的面是最优的。证明太简单所以略。
然后看这道题的二维版本:bzoj1693 [Usaco2007 Demo]Asteroids http://www.lydsy.com/JudgeOnline/problem.php?id=1693
然后这样的题一般都是一维暴力来减少一维。就枚举最小的一维打掉哪些面。然后把剩下的压成两维,然后做。
RunID | User | Problem | Result | Memory | Time | Language | Code_Length | Submit_Time |
410333 | lbz007 | 1693 | Accepted | 12032 kb | 4 ms | Pascal/Edit | 862 B | 2013-05-11 20:51:11 |
1 var 2 u,v,k,ans,i,j,n,a,ee:longint; 3 link:Array[0..2002]of longint; 4 next,head,e:array[0..1000000]of longint; 5 b:array[0..20002]of longint; 6 procedure add(u,v:longint); 7 begin 8 inc(ee); 9 next[ee]:=head[u]; 10 head[u]:=ee; 11 e[ee]:=v; 12 end; 13 14 function find(x:longint):boolean; 15 var j:longint; 16 begin 17 j:=head[x]; 18 while j<>0 do 19 begin 20 if b[e[j]]<>i then 21 begin 22 b[e[j]]:=i; 23 if (link[e[j]]=0) or (find(link[e[j]])) then 24 begin 25 link[e[j]]:=x; 26 exit(true); 27 end; 28 end; 29 j:=next[j]; 30 end; 31 exit(false); 32 end; 33 begin 34 readln(n,k); 35 for i:=1 to k do 36 begin 37 readln(u,v); 38 add(u,v); 39 end; 40 for i:=1 to n do 41 if find(i) then inc(ans); 42 writeln (ans); 43 end.
-------------------------------------------------------------------------
花有重开日,人无再少年