• bzoj1972 猪国杀 大♂模拟


    链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1972

    不要想了这个题面没有办法读的……找个可读版本:https://mubu.com/doc/2707815814591da4

    题意:给出一种$AI$人工智障打三国杀的方式,模拟出整个游戏进程。

    基本题面就这个意思……内容也没什么……但是这题目里面有好几个坑点:

    1、决斗有可能干死自己没杀打什么决斗

    2、牌堆可能摸完,摸完牌堆要一直摸最后一张这张牌会分身,摸完还有

    3、$BZOJ$样例是错的……少一张万箭齐发……

    4、题目描述与数据不符,描述中提到反贼是$AP$实际上是$FP$AntiPig?FanPig?

    5、毕竟是群人工智障……所以有的东西不能按照人类规则来……比如濒死状态别人不能出桃……能跳就跳即使这样会导致下一回合被集火……有时候无懈可击不出给自己出给主公或其他队友……

    6、每打一张牌,当前牌指针都要归位……因为你打出上一张牌之后可能有人跳了以致之前打不出的牌可以打出……

    7、反贼决斗永远出给主公!别听题面瞎$BB$……

    8、最坑的一点……这个题会$PE$……

    最后提醒一下:千万不要以这个题为契机学习$OOP$……我学习了一下,结果按照$wcx$语录只有变量名、函数名长度像$OOP$……然后代码奇长奇丑无比……在没有注释的情况下写了$12K$……而且这样很难调试……错了$35%$足足两天最后拿到数据才发现本蒟蒻决斗完了制杖地没有重新设计指针为第一张牌……

      1 #include <bits/stdc++.h>
      2 using namespace std;
      3 const int maxn=50010;
      4 int Bef[maxn],Nex[maxn],cnt;char Kind[maxn],Paidui[3010];
      5 int top,m;
      6 char Get_a_Card()
      7 {
      8     if(top!=m)top++;
      9     return Paidui[top];
     10 }
     11 int Real_Identity[15],Tot_Enemy;
     12 bool Is_Game_Over;int Now_Round;
     13 void Kill_Another_Player(int,int);
     14 void Get_Into_A_Fight_With_Another_Player(int,int);
     15 void Seek_For_A_Kill_From_Everyone(int);
     16 void Seek_For_A_Evasion_From_Everyone(int);
     17 class pig
     18 {
     19     public:
     20         int Current_Identity,Head,Last,Now,Iter;
     21         int Blood,Unassailable_Num,Heart_Num,Evasion_Num;
     22         int Att_Target,Las_Player,Nex_Player;
     23         bool Is_Dead,Equipped_Arrow;
     24         int ID_num;
     25         void Print_Cards()
     26         {
     27             int Now=Head;cout<<Blood<<endl;
     28             while(Now)cout<<Kind[Now],Now=Nex[Now];
     29             cout<<endl;
     30         }
     31         void Get_Bonus_After_Killing_An_Enemy()
     32         {
     33             cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last;
     34             if(!Head)Head=Last=cnt;
     35             else Nex[Last]=cnt,Last=cnt;
     36             switch(Kind[cnt])
     37             {
     38                 case 'J':Unassailable_Num++;break;
     39                 case 'P':Heart_Num++;break;
     40                 case 'D':Evasion_Num++;break;
     41             }
     42             cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last,Nex[Last]=cnt,Last=cnt;
     43             switch(Kind[cnt])
     44             {
     45                 case 'J':Unassailable_Num++;break;
     46                 case 'P':Heart_Num++;break;
     47                 case 'D':Evasion_Num++;break;
     48             }
     49             cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last,Nex[Last]=cnt,Last=cnt;
     50             switch(Kind[cnt])
     51             {
     52                 case 'J':Unassailable_Num++;break;
     53                 case 'P':Heart_Num++;break;
     54                 case 'D':Evasion_Num++;break;
     55             }
     56         }
     57         void Get_Punish_After_Killing_An_Teammate()
     58         {
     59             Head=Last=Now=0;
     60             Unassailable_Num=Heart_Num=Evasion_Num=0;
     61             Equipped_Arrow=0;
     62         }
     63         void Stage_When_A_Player_Get_Cards()
     64         {
     65             cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last;
     66             if(!Head)Head=Last=cnt;
     67             else Nex[Last]=cnt,Last=cnt;
     68             switch(Kind[cnt])
     69             {
     70                 case 'J':Unassailable_Num++;break;
     71                 case 'P':Heart_Num++;break;
     72                 case 'D':Evasion_Num++;break;
     73             }
     74             cnt++;Kind[cnt]=Get_a_Card();Bef[cnt]=Last,Nex[Last]=cnt,Last=cnt;
     75             switch(Kind[cnt])
     76             {
     77                 case 'J':Unassailable_Num++;break;
     78                 case 'P':Heart_Num++;break;
     79                 case 'D':Evasion_Num++;break;
     80             }
     81         }
     82         void Stage_When_A_Player_Tries_To_Use_A_Card(int x)
     83         {
     84             switch(Kind[x])
     85             {
     86                 case 'J':Unassailable_Num--;break;
     87                 case 'P':Heart_Num--;break;
     88                 case 'D':Evasion_Num--;break;
     89             }
     90             if(x==Head&&x==Last)Head=Last=0;
     91             else if(x==Head)Head=Nex[x],Bef[Nex[x]]=0;
     92             else if(x==Last)Last=Bef[x],Nex[Bef[x]]=0;
     93             else Bef[Nex[x]]=Bef[x],Nex[Bef[x]]=Nex[x];
     94         }
     95         char Show_A_Players_Next_Card()
     96         {
     97             if(!Now)return 0;
     98             Iter=Now;Now=Nex[Now];
     99             return Kind[Iter];
    100         }
    101         void Output_The_Final_Answer()
    102         {
    103             if(Is_Dead)puts("DEAD");
    104             else
    105             {
    106                 while(Head)
    107                 {
    108                     cout<<Kind[Head];
    109                     if(Head!=Last)putchar(' ');
    110                     Head=Nex[Head];
    111                 }
    112                 puts("");
    113             }
    114         }
    115         int Get_The_ID_Of_The_First_Evasion()
    116         {
    117             Now=Head;char tmp;
    118             while(tmp=Show_A_Players_Next_Card())
    119                 if(tmp=='D')return Iter;
    120         }
    121         int Get_The_ID_Of_The_First_Heart()
    122         {
    123             Now=Head;char tmp;
    124             while(tmp=Show_A_Players_Next_Card())
    125                 if(tmp=='P')return Iter;
    126         }
    127         int Get_The_ID_Of_The_First_Unassailable()
    128         {
    129             Now=Head;char tmp;
    130             while(tmp=Show_A_Players_Next_Card())
    131                 if(tmp=='J')return Iter;
    132         }
    133         bool Try_To_Use_A_Kill()
    134         {
    135             Now=Head;char tmp;
    136             while(tmp=Show_A_Players_Next_Card())
    137                 if(tmp=='K'){Stage_When_A_Player_Tries_To_Use_A_Card(Iter);return 1;}
    138             return 0;
    139         }
    140         bool Try_To_Use_A_Evasion()
    141         {
    142             if(Evasion_Num){Stage_When_A_Player_Tries_To_Use_A_Card(Get_The_ID_Of_The_First_Evasion());return 1;}
    143             return 0;
    144         }
    145         bool Try_To_Use_A_Heart()
    146         {
    147             if(Heart_Num){Stage_When_A_Player_Tries_To_Use_A_Card(Get_The_ID_Of_The_First_Heart());return 1;}
    148             return 0;
    149         }
    150         bool Try_To_Use_A_Unassailable()
    151         {
    152             if(Unassailable_Num){Stage_When_A_Player_Tries_To_Use_A_Card(Get_The_ID_Of_The_First_Unassailable());return 1;}
    153             return 0;
    154         }
    155         void One_Players_Round()
    156         {
    157             Stage_When_A_Player_Get_Cards();
    158             Now=Head;char tmp;bool Kill_Has_Used=0;
    159             while((tmp=Show_A_Players_Next_Card())&&!Is_Game_Over)
    160             {
    161                 switch(tmp)
    162                 {
    163                     case 'D':break;
    164                     case 'J':break;
    165                     case 'P':if(Blood!=4)Blood++,Stage_When_A_Player_Tries_To_Use_A_Card(Iter);break;
    166                     case 'K':if(Att_Target==Nex_Player)
    167                                 if(!Kill_Has_Used||Equipped_Arrow)
    168                                 {
    169                                     Stage_When_A_Player_Tries_To_Use_A_Card(Iter),Kill_Another_Player(ID_num,Att_Target);
    170                                     Now=Head;Kill_Has_Used=1;
    171                                     if(Is_Game_Over)return;
    172                                 }
    173                             break;
    174                     case 'F':if(!Att_Target)break;
    175                                 Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
    176                                 if(Real_Identity[ID_num]==3)Get_Into_A_Fight_With_Another_Player(ID_num,1);
    177                                 else Get_Into_A_Fight_With_Another_Player(ID_num,Att_Target);
    178                                 if(Is_Game_Over||Is_Dead)return;
    179                                 Now=Head;
    180                                 break;
    181                     case 'N':Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
    182                                 Seek_For_A_Kill_From_Everyone(ID_num);Now=Head;
    183                                 if(Is_Game_Over)return;
    184                                 break;
    185                     case 'W':Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
    186                                 Seek_For_A_Evasion_From_Everyone(ID_num);Now=Head;
    187                                 if(Is_Game_Over)return;
    188                                 break;
    189                     case 'Z':Stage_When_A_Player_Tries_To_Use_A_Card(Iter);
    190                                 Equipped_Arrow=1;Now=Head;break;
    191                 }
    192             }
    193         }
    194 }Players[11];
    195 void Refresh_The_Infection_Of_One_Player_In_Everyones_Mind(int x)
    196 {
    197     int y=Players[x].Nex_Player;
    198     switch(Real_Identity[x])
    199     {
    200         case 1:while(y!=x)
    201             {
    202                 if(Players[y].Current_Identity==1||Players[y].Current_Identity==3){Players[x].Att_Target=y;return;}
    203                 y=Players[y].Nex_Player;
    204             }
    205             Players[x].Att_Target=0;break;
    206         case 2:while(y!=x)
    207                 {
    208                     if(Players[y].Current_Identity==3){Players[x].Att_Target=y;return;}
    209                     y=Players[y].Nex_Player;
    210                 }
    211                 Players[x].Att_Target=0;break;
    212         case 3:while(y!=x)
    213                     {
    214                         if(Players[y].Current_Identity==2||Real_Identity[y]==1){Players[x].Att_Target=y;return;}
    215                         y=Players[y].Nex_Player;
    216                     }
    217                     Players[x].Att_Target=0;
    218     }
    219 }
    220 void Every_Player_Try_To_Refresh_Their_Infection()
    221 {
    222     int x=Players[1].Nex_Player;Refresh_The_Infection_Of_One_Player_In_Everyones_Mind(1);
    223     while(x!=1)Refresh_The_Infection_Of_One_Player_In_Everyones_Mind(x),x=Players[x].Nex_Player;
    224 }
    225 void A_Player_Was_Killed_By_Another_One(int x,int y)
    226 {
    227     Players[y].Is_Dead=1;
    228     if(Real_Identity[y]==1){Is_Game_Over=1;return;}
    229     if(Real_Identity[y]==3)
    230     {
    231         Tot_Enemy--;
    232         if(!Tot_Enemy){Is_Game_Over=1;return;}
    233         Players[x].Get_Bonus_After_Killing_An_Enemy();
    234     }
    235     if(Real_Identity[y]==2&&Real_Identity[x]==1)Players[x].Get_Punish_After_Killing_An_Teammate();
    236     int BEFO=Players[y].Las_Player,NEXT=Players[y].Nex_Player;
    237     Players[BEFO].Nex_Player=NEXT,Players[NEXT].Las_Player=BEFO;
    238     Every_Player_Try_To_Refresh_Their_Infection();
    239 }
    240 void A_Player_Was_Wounded_By_Another_One(int x,int y)
    241 {
    242     Players[y].Blood--;
    243     if(!Players[y].Blood)
    244         if(Players[y].Try_To_Use_A_Heart())Players[y].Blood++;
    245         else A_Player_Was_Killed_By_Another_One(x,y);
    246 }
    247 void Kill_Another_Player(int x,int y)
    248 {
    249     if(Real_Identity[x]!=1&&Players[x].Current_Identity<2)
    250     {
    251         if(Real_Identity[y]==3)Players[x].Current_Identity=2;
    252         else Players[x].Current_Identity=3;
    253         Every_Player_Try_To_Refresh_Their_Infection();
    254     }
    255     if(Players[y].Try_To_Use_A_Evasion())return;
    256     A_Player_Was_Wounded_By_Another_One(x,y);
    257 }
    258 bool Start_An_Unassailable_Cycle(int st,bool Is_He_An_Enemy)
    259 {
    260     bool ST=Is_He_An_Enemy;int Last_One_Who_Show_An_Unassailble=st,x=st;
    261     if(Is_He_An_Enemy==(Real_Identity[x]==3))
    262         if(Players[x].Try_To_Use_A_Unassailable())
    263         {
    264             Last_One_Who_Show_An_Unassailble=x,Is_He_An_Enemy^=1;
    265             if(Players[x].Current_Identity<=2)Players[x].Current_Identity=3-Is_He_An_Enemy,Every_Player_Try_To_Refresh_Their_Infection();
    266         }
    267     x=Players[x].Nex_Player;
    268     while(x!=Last_One_Who_Show_An_Unassailble)
    269     {
    270         if(Is_He_An_Enemy==(Real_Identity[x]==3))
    271             if(Players[x].Try_To_Use_A_Unassailable())
    272             {
    273                 Last_One_Who_Show_An_Unassailble=x,Is_He_An_Enemy^=1;
    274                 if(Players[x].Current_Identity<=2)Players[x].Current_Identity=3-Is_He_An_Enemy,Every_Player_Try_To_Refresh_Their_Infection();
    275             }
    276         x=Players[x].Nex_Player;
    277     }
    278     return (ST!=Is_He_An_Enemy);
    279 }
    280 void Get_Into_A_Fight_With_Another_Player(int x,int y)
    281 {
    282     if(Real_Identity[x]!=1&&Players[x].Current_Identity<2)
    283     {
    284         if(Real_Identity[y]==3)Players[x].Current_Identity=2;
    285         else Players[x].Current_Identity=3;
    286         Every_Player_Try_To_Refresh_Their_Infection();
    287     }
    288     if(Real_Identity[y]==1||Players[y].Current_Identity>=2)
    289     {
    290         if(Real_Identity[y]==1||Players[y].Current_Identity==2)
    291         {
    292             if(Start_An_Unassailable_Cycle(x,0))return;
    293         }
    294         else if(Start_An_Unassailable_Cycle(x,1))return;
    295     }
    296     if(Real_Identity[x]==1&&Real_Identity[y]==2)A_Player_Was_Wounded_By_Another_One(x,y);
    297     else while(1)
    298     {
    299         if(!Players[y].Try_To_Use_A_Kill()){A_Player_Was_Wounded_By_Another_One(x,y);return;}
    300         if(!Players[x].Try_To_Use_A_Kill()){A_Player_Was_Wounded_By_Another_One(y,x);return;}
    301     }
    302 }
    303 void Seek_For_A_Kill_From_Everyone(int x)
    304 {
    305     int y=Players[x].Nex_Player;
    306     while(y!=x)
    307     {
    308         if(Real_Identity[y]==1||Players[y].Current_Identity>=2)
    309         {
    310             if(Real_Identity[y]==1||Players[y].Current_Identity==2)
    311             {
    312                 if(Start_An_Unassailable_Cycle(x,0)){y=Players[y].Nex_Player;continue;}
    313             }
    314             else if(Start_An_Unassailable_Cycle(x,1)){y=Players[y].Nex_Player;continue;}
    315         }
    316         if(!Players[y].Try_To_Use_A_Kill())
    317         {
    318             A_Player_Was_Wounded_By_Another_One(x,y);
    319             if(Is_Game_Over)return;
    320             if(y==1&&Players[x].Current_Identity==0)Players[x].Current_Identity=1,Every_Player_Try_To_Refresh_Their_Infection();
    321         }
    322         y=Players[y].Nex_Player;
    323     }
    324 }
    325 void Seek_For_A_Evasion_From_Everyone(int x)
    326 {
    327     int y=Players[x].Nex_Player;
    328     while(y!=x)
    329     {
    330         if(Real_Identity[y]==1||Players[y].Current_Identity>=2)
    331         {
    332             if(Real_Identity[y]==1||Players[y].Current_Identity==2)
    333             {
    334                 if(Start_An_Unassailable_Cycle(x,0)){y=Players[y].Nex_Player;continue;}
    335             }
    336             else if(Start_An_Unassailable_Cycle(x,1)){y=Players[y].Nex_Player;continue;}
    337         }
    338         if(!Players[y].Try_To_Use_A_Evasion())
    339         {
    340             A_Player_Was_Wounded_By_Another_One(x,y);
    341             if(Is_Game_Over)return;
    342             if(y==1&&!Players[x].Current_Identity)Players[x].Current_Identity=1,Every_Player_Try_To_Refresh_Their_Infection();
    343         }
    344         y=Players[y].Nex_Player;
    345     }
    346 }
    347 int haha()
    348 {
    349     freopen("kopk.in","r",stdin);
    350     freopen("kopk.out","w",stdout);
    351     int n;scanf("%d%d",&n,&m);
    352     int x=0;char opt[10];
    353     for(int i=1;i<n;i++)Players[i].Nex_Player=i+1;Players[n].Nex_Player=1;
    354     Players[1].Las_Player=n;for(int i=2;i<=n;i++)Players[i].Las_Player=i-1;
    355     for(int i=1;i<=n;i++)
    356     {
    357         scanf("%s",opt);
    358         switch(opt[0])
    359         {
    360             case 'M':Real_Identity[i]=1;break;
    361             case 'Z':Real_Identity[i]=2;break;
    362             case 'F':Real_Identity[i]=3,Tot_Enemy++;break;
    363         }
    364         scanf("%s",opt),x++,Paidui[x]=opt[0];
    365         scanf("%s",opt),x++,Paidui[x]=opt[0];
    366         scanf("%s",opt),x++,Paidui[x]=opt[0];
    367         scanf("%s",opt),x++,Paidui[x]=opt[0];
    368     }
    369     for(int i=1;i<=m;i++)scanf("%s",opt),x++,Paidui[x]=opt[0];
    370     m+=4*n;
    371     for(int i=1;i<=n;i++)
    372         Players[i].Stage_When_A_Player_Get_Cards(),Players[i].Stage_When_A_Player_Get_Cards(),
    373         Players[i].ID_num=i,Players[i].Blood=4;
    374     int now=1;Every_Player_Try_To_Refresh_Their_Infection();
    375     while(!Is_Game_Over)Now_Round=now,Players[now].One_Players_Round(),now=Players[now].Nex_Player;
    376     if(Players[1].Is_Dead)puts("FP");else puts("MP");
    377     for(int i=1;i<=n;i++)Players[i].Output_The_Final_Answer();
    378 }
    379 int sb=haha();
    380 int main(){;}
    bzoj1972

    代码拿走吧……真的很乱七八糟……

  • 相关阅读:
    pip install
    自动更新高清电影文件中文名
    csv、excel导入oracle
    02_Jenkins配置任务
    01_Jenkins windows安装
    run_jmeter.py
    02_禅道的基本使用
    01_禅道搭建手册
    01_charles 下载安装(破解版)
    06_Linux常见的命令
  • 原文地址:https://www.cnblogs.com/Loser-of-Life/p/7652983.html
Copyright © 2020-2023  润新知