【bzoj2548】灭鼠行动解题报告

来源:互联网 发布:华为云计算部门在哪里 编辑:程序博客网 时间:2024/05/17 07:42

嘛。。。。活(和谐)捉大摸(和谐)你题一道。。。

零零散散码了10k。。。。。。等等CTL学长是怎么做到5k的QAQ。。在这里送上蒟蒻未来初三一年的膝盖!!!CTL是我学长我是他小号!!!

const  runx:array[1..4]of longint=(-1,0,1,0);  runy:array[1..4]of longint=(0,1,0,-1);type  nodebomb=record  leixing,x,y,time:longint;  end;  noderat=record  x,y,sex,think,waketime,adulttime,alivetime,borntime:longint;  toward:longint;  alive,awake,adult:boolean  end;  node4=record  x,y:longint;  end;var  bomb:array[0..200]of nodebomb;  rat:array[0..10000]of noderat;  map:array[0..100,0..100,1..4]of boolean;  bombu:array[0..51,0..51]of boolean;  dl:array[0..10000]of node4;  dep:array[0..10000]of longint;  num:array[0..50,0..50]of longint;  i,j,k,n,m,temp,ratnum,maxrat,bombnum:longint;  qianglizhadandegongjifanwei,shenmizhadandegongjifanwei,endtime,lll,time,tot,preee:longint;  ch:char;procedure qsort1(l,r:longint);var i,j,mid:longint;t:nodebomb;begin  i:=l;j:=r;mid:=bomb[(l+r)shr 1].time;  repeat    while bomb[i].time<mid do inc(i);    while bomb[j].time>mid do dec(j);    if i<=j then    begin      t:=bomb[i];bomb[i]:=bomb[j];bomb[j]:=t;      inc(i);dec(j)    end  until i>j;  if i<r then qsort1(i,r);  if l<j then qsort1(l,j)end;procedure init;begin  readln(qianglizhadandegongjifanwei,shenmizhadandegongjifanwei,m,n);  for i:=1 to m do  for j:=1 to n do  begin    read(temp);    if temp>=8 then    begin      dec(temp,8);      map[i,j,4]:=true    end;    if temp>=4 then    begin      dec(temp,4);      map[i,j,3]:=true    end;    if temp>=2 then    begin      dec(temp,2);      map[i,j,2]:=true    end;    if temp>=1 then    begin      dec(temp);      map[i,j,1]:=true    end  end;  readln(ratnum);  for i:=1 to ratnum do  begin    read(temp);    rat[i].x:=temp;    read(temp);    rat[i].y:=temp;    read(ch);    read(ch);    if ch='N' then rat[i].toward:=1;    if ch='E' then rat[i].toward:=2;    if ch='S' then rat[i].toward:=3;    if ch='W' then rat[i].toward:=4;    read(ch);    readln(ch);    if ch='X' then rat[i].sex:=1    else rat[i].sex:=0;    rat[i].alive:=true;    rat[i].adult:=true;    rat[i].awake:=true;    rat[i].think:=0;    rat[i].waketime:=0;    rat[i].borntime:=-1;    rat[i].alivetime:=0;  end;  readln(bombnum,maxrat);  for i:=1 to bombnum do  begin    readln(bomb[i].leixing,bomb[i].time,bomb[i].x,bomb[i].y);    if bomb[i].leixing=3 then inc(bomb[i].time,3)  end;  readln(endtime);  qsort1(1,bombnum);//  for i:=1 to bombnum do writeln(bomb[i].leixing,' ',bomb[i].time,' ',bomb[i].x,' ',bomb[i].y);end;function can:boolean;var i:longint;tot:longint;begin  tot:=0;  for i:=1 to ratnum do  if rat[i].alive then inc(tot);  if tot>maxrat then exit(false)  else exit(true)end;procedure bfs1;var l,r:longint;now:node4;i,j,k,depp,nowx,nowy:longint;begin  fillchar(bombu,sizeof(bombu),false);//  fillchar(dep,sizeof(dep),0);  l:=0;r:=1;dl[1].x:=bomb[lll].x;dl[1].y:=bomb[lll].y;  bombu[dl[1].x,dl[1].y]:=true;  {dep[1]:=0;  while l<r do  begin    inc(l);    now:=dl[l];    if dep[l]<qianglizhadandegongjifanwei then    for i:=1 to 4 do    if (map[now.x,now.y,i])and    ((now.x+runx[i]>=1)and(now.x+runx[i]<=m)and(now.y+runy[i]>=1)and(now.y+runy[i]<=n))    and(not bombu[now.x+runx[i],now.y+runy[i]]) then    begin      bombu[now.x+runx[i],now.y+runy[i]]:=true;      inc(r);      dep[r]:=dep[l]+1;      dl[r].x:=now.x+runx[i];      dl[r].y:=now.y+runy[i]    end  end;      }  for i:=1 to 4 do  begin    nowx:=bomb[lll].x;    nowy:=bomb[lll].y;    depp:=0;    while map[nowx,nowy,i]do    begin      nowx:=nowx+runx[i];      nowy:=nowy+runy[i];      bombu[nowx,nowy]:=true;      inc(depp);      if depp>=qianglizhadandegongjifanwei then break    end;  end;  for i:=1 to ratnum do  if rat[i].alive then  if bombu[rat[i].x,rat[i].y]then rat[i].alive:=falseend;procedure bombrun;var i,j,k,l,r:longint;begin  while (lll<=bombnum)and(bomb[lll].time=time) do  begin    if bomb[lll].leixing=1 then      bfs1;    if bomb[lll].leixing=2 then    begin      for i:=1 to ratnum do      if (sqrt(sqr(rat[i].x-bomb[lll].x)+sqr(rat[i].y-bomb[lll].y))<=shenmizhadandegongjifanwei)and(rat[i].alive) then      begin        rat[i].awake:=false;        inc(rat[i].waketime,3);        if rat[i].borntime>time then inc(rat[i].borntime,3)      end    end;    if bomb[lll].leixing=3 then    begin      for i:=1 to ratnum do      if (rat[i].x=bomb[lll].x)and(rat[i].y=bomb[lll].y)and(rat[i].alive)then      rat[i].alive:=false    end;    if bomb[lll].leixing=4 then    begin      for i:=1 to ratnum do      if (rat[i].x=bomb[lll].x)and(rat[i].y=bomb[lll].y)and(rat[i].alive)then      rat[i].sex:=rat[i].sex xor 1    end;    inc(lll)  endend;procedure bornrun;var i,j:longint;begin  fillchar(num,sizeof(num),0);  for i:=1 to ratnum do  if rat[i].alive then inc(num[rat[i].x,rat[i].y]);  for i:=1 to ratnum do    if (rat[i].alive)and(rat[i].sex=1)and(num[rat[i].x,rat[i].y]=2)and(rat[i].borntime=-1)and(rat[i].adult)and(rat[i].waketime<=0)then      for j:=1 to ratnum do        if (rat[j].alive)and(rat[j].sex=0)and(rat[j].x=rat[i].x)and(rat[j].y=rat[i].y)and(rat[j].borntime=-1)and(rat[j].adult)and(rat[j].waketime<=0)then        begin//          writeln(i,'XXOO',j,'//',time);          inc(rat[i].waketime,3);          rat[i].borntime:=time+2;          inc(rat[j].waketime,3);          rat[j].borntime:=time+2;          break        end;//  if time=8 then writeln(rat[9].x,' ',rat[13].x,' ',rat[9].y,' ',rat[13].y,' ',rat[9].borntime,' ',rat[13].borntime,' ',rat[9].waketime,' ',rat[13].waketime,' ',rat[9].sex,' ',rat[13].sex);  for i:=1 to ratnum do  if (rat[i].borntime=time)and(rat[i].sex=1)and(rat[i].alive) then  begin//    writeln(' ',i);    preee:=ratnum;    if map[rat[i].x,rat[i].y,1] then    begin      inc(ratnum);      rat[ratnum].x:=rat[i].x;      rat[ratnum].y:=rat[i].y;      rat[ratnum].alive:=true;      rat[ratnum].borntime:=-1;      rat[ratnum].toward:=1;      rat[ratnum].sex:=1;      rat[ratnum].adult:=false;      rat[ratnum].alivetime:=0;      rat[ratnum].waketime:=0;      rat[ratnum].think:=0;      rat[ratnum].awake:=true    end;    if map[rat[i].x,rat[i].y,3]then    begin      inc(ratnum);      rat[ratnum].x:=rat[i].x;      rat[ratnum].y:=rat[i].y;      rat[ratnum].alive:=true;      rat[ratnum].borntime:=-1;      rat[ratnum].toward:=3;      rat[ratnum].sex:=1;      rat[ratnum].adult:=false;      rat[ratnum].alivetime:=0;      rat[ratnum].waketime:=0;      rat[ratnum].think:=0;      rat[ratnum].awake:=true    end;    if map[rat[i].x,rat[i].y,2]then    begin      inc(ratnum);      rat[ratnum].x:=rat[i].x;      rat[ratnum].y:=rat[i].y;      rat[ratnum].alive:=true;      rat[ratnum].borntime:=-1;      rat[ratnum].toward:=2;      rat[ratnum].sex:=0;      rat[ratnum].adult:=false;      rat[ratnum].alivetime:=0;      rat[ratnum].waketime:=0;      rat[ratnum].think:=0;      rat[ratnum].awake:=true    end;    if map[rat[i].x,rat[i].y,4]then    begin      inc(ratnum);      rat[ratnum].x:=rat[i].x;      rat[ratnum].y:=rat[i].y;      rat[ratnum].alive:=true;      rat[ratnum].borntime:=-1;      rat[ratnum].toward:=4;      rat[ratnum].sex:=0;      rat[ratnum].adult:=false;      rat[ratnum].alivetime:=0;      rat[ratnum].waketime:=0;      rat[ratnum].think:=0;      rat[ratnum].awake:=true    end  endend;procedure ratrun;var i,j,k:longint;begin  for i:=1 to ratnum do  if (rat[i].alive) then  if rat[i].waketime<=0 then  begin    rat[i].awake:=true;    rat[i].borntime:=-1;    if map[rat[i].x,rat[i].y,rat[i].toward] then    begin      rat[i].x:=rat[i].x+runx[rat[i].toward];      rat[i].y:=rat[i].y+runy[rat[i].toward]    end    else    begin      if map[rat[i].x,rat[i].y,(rat[i].toward+1-1)mod 4+1]and(map[rat[i].x,rat[i].y,(rat[i].toward+3-1)mod 4+1])then      begin        inc(rat[i].think);        if rat[i].think mod 2=1 then rat[i].toward:=(rat[i].toward+3-1)mod 4+1        else rat[i].toward:=(rat[i].toward+1-1)mod 4+1      end      else      if map[rat[i].x,rat[i].y,(rat[i].toward+1-1)mod 4+1]then rat[i].toward:=(rat[i].toward+1-1)mod 4+1      else      if map[rat[i].x,rat[i].y,(rat[i].toward+3-1)mod 4+1]then rat[i].toward:=(rat[i].toward+3-1)mod 4+1      else rat[i].toward:=(rat[i].toward+1-1)mod 4+1    end;    inc(rat[i].alivetime);    if rat[i].alivetime=5 then rat[i].adult:=true;  end  else dec(rat[i].waketime)end;procedure beat;var lll:longint;begin  lll:=1;  for time:=0 to endtime do  begin    bombrun;    bornrun;    if not can then begin writeln(-1); halt end;    if time<endtime then    ratrun  endend;begin  init;  beat;  tot:=0;  for i:=1 to ratnum do if rat[i].alive then begin inc(tot);{write(i,'&&');}end;//  writeln;  writeln(tot);end.

​其实也不长吧。。。。。。液体战争随便500+。。。。。。QAQ

不知道为什么百度空间里说“内容包含不合适内容,请检查后再发”= =

0 0