zoukankan      html  css  js  c++  java
  • 1972: [Sdoi2010]猪国杀

    题目太长,我只发链接吧

    wikioi(排版看起来舒服一点):http://www.wikioi.com/problem/1834/

    bzoj:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1972

    首先是题目的样例错了,第三个人有6个J

    还有,数据有问题,第1,2个点牌不够用,抽完了就一直抽最后一张牌

    调了一天多,我的模拟能力真TM差啊

    犯了几个傻逼错误

    1.让死人(反贼)继续出牌,用南蛮入侵杀死队友,导致主公获胜

    2.主公杀死忠臣没有弃装备,后来用诸葛连杀掉反贼获胜

    3.最烦的就是无懈可击的顺序了,先从出锦囊的人开始逆时针献殷勤,如果被无懈可击了,就回到上一个献殷勤的人的下家开始献殷勤(一开始直接往后,点都是交替错的(A对B就错),就是没有全对)

      1 type
      2         aa=array[0..2010]of char;
      3         pig=record
      4           pai:aa;
      5           blood,num:longint;
      6           zhuge,tiaozhong,tiaofan,leifan,sha:boolean;
      7           shenfen:char;
      8         end;
      9 var
     10         a:array[0..10]of pig;
     11         p:array[0..2010]of char;
     12         n,m,now,fanzeishu:longint;
     13  
     14 procedure print;
     15 var
     16         i,j:longint;
     17 begin
     18         for i:=1 to n do
     19           with a[i] do
     20             begin
     21               if blood>0 then
     22                 begin
     23                   for j:=1 to num do
     24                     if j<num then write(pai[j],' ')
     25                     else write(pai[j]);
     26                 end
     27               else write('DEAD');
     28               writeln;
     29             end;
     30         halt;
     31 end;
     32  
     33 procedure MPwin;
     34 begin
     35         writeln('MP');
     36         print;
     37 end;
     38  
     39 procedure FPwin;
     40 begin
     41         writeln('FP');
     42         print;
     43 end;
     44  
     45 procedure init;
     46 var
     47         i,j:longint;
     48 begin
     49         readln(n,m);
     50         for i:=1 to n do
     51           with a[i] do
     52           begin
     53             read(shenfen,pai[0]);
     54             if shenfen='F' then inc(fanzeishu);
     55             for j:=1 to 4 do
     56               read(pai[j+1],pai[j]);
     57             blood:=4;
     58             num:=4;
     59             readln;
     60           end;
     61         a[1].tiaozhong:=true;
     62         if fanzeishu=0 then MPwin;
     63         for i:=1 to m do
     64           read(p[i],p[i+1]);
     65         now:=1;
     66 end;
     67  
     68 procedure delete(var pai:aa;x:longint;var num:longint);
     69 var
     70         i:longint;
     71 begin
     72         for i:=x to num-1 do
     73           pai[i]:=pai[i+1];
     74         dec(num);
     75 end;
     76  
     77 function next(x:longint):longint;
     78 begin
     79         while true do
     80           begin
     81             x:=x mod n+1;
     82             if a[x].blood>0 then exit(x);
     83           end;
     84 end;
     85  
     86 function diyi(x,y:longint):boolean;
     87 begin
     88         exit(((a[x].shenfen='F') and (a[y].tiaozhong)) or ((a[x].shenfen<>'F') and (a[y].tiaofan)) or ((x=1) and (a[y].leifan)));
     89 end;
     90  
     91 function youjun(x,y:longint):boolean;
     92 begin
     93         exit(((a[x].shenfen='F') and (a[y].tiaofan)) or ((a[x].shenfen<>'F') and (a[y].tiaozhong)));
     94 end;
     95  
     96 procedure mopai(x:longint);
     97 begin
     98         if now>m then now:=m;
     99         with a[x] do
    100           begin
    101             inc(num);
    102             pai[num]:=p[now];
    103             inc(now);
    104           end;
    105 end;
    106  
    107 procedure tiao(x:longint);
    108 begin
    109         with a[x] do
    110           begin
    111             if shenfen='F' then tiaofan:=true
    112             else tiaozhong:=true;
    113             leifan:=false;
    114           end;
    115 end;
    116  
    117 function chupai(x:longint;c:char):boolean;
    118 var
    119         i:longint;
    120 begin
    121         with a[x] do
    122           begin
    123             for i:=1 to num do
    124               if pai[i]=c then
    125               begin
    126                 delete(pai,i,num);
    127                 exit(true);
    128               end;
    129             exit(false);
    130           end;
    131 end;
    132  
    133 procedure kill(x,y:longint);
    134 begin
    135         if a[y].shenfen='F' then
    136         begin
    137           mopai(x);
    138           mopai(x);
    139           mopai(x);
    140         end;
    141         if (x=1) and (a[y].shenfen='Z') then
    142         begin
    143           a[x].num:=0;
    144           a[x].zhuge:=false;
    145         end;
    146 end;
    147  
    148 procedure decblood(x:longint);
    149 begin
    150         with a[x] do
    151           begin
    152             dec(blood);
    153             if blood=0 then
    154             begin
    155               if chupai(x,'P')=false then
    156                 begin
    157                   if shenfen='F' then dec(fanzeishu);
    158                   if fanzeishu=0 then MPwin;
    159                   if shenfen='M' then FPwin;
    160                 end
    161               else blood:=1;
    162             end;
    163           end;
    164 end;
    165  
    166 function dixiao(x:longint):boolean;
    167 var
    168         i:longint;
    169 begin
    170         i:=next(x);
    171         while i<>x do
    172           begin
    173             if diyi(i,x) and chupai(i,'J') then
    174             begin
    175               tiao(i);
    176               exit(true);
    177             end;
    178             i:=next(i);
    179           end;
    180         exit(false);
    181 end;
    182  
    183 procedure gongji(x,y:longint);
    184 begin
    185         if chupai(y,'D')=false then
    186         begin
    187           decblood(y);
    188           if a[y].blood=0 then kill(x,y);
    189         end;
    190 end;
    191  
    192 function jiuyuan(x,k:longint):boolean;
    193 var
    194         i:longint;
    195 flag:boolean;
    196 begin
    197         i:=k;
    198         flag:=true;
    199         while true do
    200           begin
    201             if (i=k) and (flag=false) then break;
    202             if i=k then flag:=false;
    203             if (youjun(i,x)) and (chupai(i,'J')) then
    204             begin
    205               tiao(i);
    206               flag:=true;
    207               if not dixiao(i) then exit(true);
    208             end;
    209             i:=next(i);
    210           end;
    211         exit(false);
    212 end;
    213  
    214 procedure fight(x,y:longint);
    215 begin
    216         if (x=1) and (a[y].shenfen='Z') then
    217           begin
    218             decblood(y);
    219             if a[y].blood=0 then kill(x,y);
    220           end
    221         else
    222           if jiuyuan(y,x)=false then
    223             begin
    224               while true do
    225                 begin
    226                   if chupai(y,'K')=false then
    227                   begin
    228                     decblood(y);
    229                     if a[y].blood=0 then kill(x,y);
    230                     exit;
    231                   end;
    232                   if chupai(x,'K')=false then
    233                   begin
    234                     decblood(x);
    235                     if a[x].blood=0 then kill(y,x);
    236                     exit;
    237                   end;
    238                 end;
    239             end;
    240 end;
    241  
    242 procedure nanman(x:longint);
    243 var
    244         i:longint;
    245 begin
    246         i:=next(x);
    247         while i<>x do
    248           begin
    249             if jiuyuan(i,x)=false then
    250             begin
    251               if chupai(i,'K')=false then
    252               begin
    253                 decblood(i);
    254                 if (i=1) and (not a[x].tiaozhong) and (not a[x].tiaofan) then a[x].leifan:=true;
    255                 if a[i].blood=0 then kill(x,i);
    256               end;
    257             end;
    258             i:=next(i);
    259           end;
    260 end;
    261  
    262 procedure wanjian(x:longint);
    263 var
    264         i:longint;
    265 begin
    266         i:=next(x);
    267         while i<>x do
    268           begin
    269             if jiuyuan(i,x)=false then
    270             begin
    271               if chupai(i,'D')=false then
    272               begin
    273                 decblood(i);
    274                 if (i=1) and (not a[x].tiaozhong) and (not a[x].tiaofan) then a[x].leifan:=true;
    275                 if a[i].blood=0 then kill(x,i);
    276               end;
    277             end;
    278             i:=next(i);
    279           end;
    280 end;
    281  
    282 procedure xingdong(x:longint);
    283 var
    284         i,k:longint;
    285 begin
    286         i:=1;
    287         with a[x] do
    288           while i<=num do
    289             begin
    290               if a[x].blood=0 then exit;
    291               if pai[i]='N' then
    292               begin
    293                 delete(pai,i,num);
    294                 nanman(x);
    295                 i:=1;
    296                 continue;
    297               end;
    298               if pai[i]='W' then
    299               begin
    300                 delete(pai,i,num);
    301                 wanjian(x);
    302                 i:=1;
    303                 continue;
    304               end;
    305               if (pai[i]='K') and ((not sha) or zhuge) then
    306               begin
    307                 k:=next(x);
    308                 if diyi(x,k) then
    309                 begin
    310                   delete(pai,i,num);
    311                   tiao(x);
    312                   gongji(x,k);
    313                   sha:=true;
    314                   i:=1;
    315                   continue;
    316                 end;
    317               end;
    318               if pai[i]='F' then
    319               begin
    320                 k:=next(x);
    321                 if x=1 then
    322                 begin
    323                   while k<>x do
    324                     begin
    325                       if diyi(x,k) then
    326                       begin
    327                         delete(pai,i,num);
    328                         break;
    329                       end;
    330                       k:=next(k);
    331                     end;
    332                   if k<>x then
    333                   begin
    334                     fight(x,k);
    335                     i:=1;
    336                     continue;
    337                   end;
    338                 end;
    339                 if shenfen='F' then
    340                 begin
    341                   delete(pai,i,num);
    342                   tiao(x);
    343                   fight(x,1);
    344                   i:=1;
    345                   continue;
    346                 end;
    347                 if shenfen='Z' then
    348                 begin
    349                   while k<>x do
    350                     begin
    351                       if diyi(x,k) then
    352                       begin
    353                         delete(pai,i,num);
    354                         break;
    355                       end;
    356                       k:=next(k);
    357                     end;
    358                   if k<>x then
    359                   begin
    360                     tiao(x);
    361                     fight(x,k);
    362                     i:=1;
    363                     continue;
    364                   end;
    365                 end;
    366               end;
    367               if (pai[i]='P') and (blood<4) then
    368               begin
    369                 inc(blood);
    370                 delete(pai,i,num);
    371                 i:=1;
    372                 continue;
    373               end;
    374               if pai[i]='Z' then
    375               begin
    376                 zhuge:=true;
    377                 delete(pai,i,num);
    378                 i:=1;
    379                 continue;
    380               end;
    381               inc(i);
    382             end;
    383 end;
    384  
    385 procedure work;
    386 var
    387         i:longint;
    388 begin
    389         i:=0;
    390         while true do
    391           begin
    392             i:=i mod n+1;
    393             if a[i].blood=0 then continue;
    394             mopai(i);
    395             mopai(i);
    396             a[i].sha:=false;
    397             xingdong(i);
    398           end;
    399 end;
    400  
    401 begin
    402         init;
    403         work;
    404 end.
    View Code
  • 相关阅读:
    Linux性能及调优指南(翻译)之Linux内存架构
    dtrace4linux
    perlchina2016 大会
    GO 语言圣经 -在线阅读
    dtrace4linux_Example
    hellogcc -100GDB技巧
    ITGEGE在线教育
    编译系统透视:图解编译原理
    C 高级编程5 IO与文件权限
    C 高级编程4 makefile 与 IO
  • 原文地址:https://www.cnblogs.com/Randolph87/p/3667936.html
Copyright © 2011-2022 走看看