先放码
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
#define Sakura int
#define Re register int
#define _ putchar(' ')
#define el putchar('\n')
using namespace std;
const int maxn=15;
inline int read(){
int x=0,f=0;char c=getchar();
while(!isdigit(c)) f|=c=='-',c=getchar();
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
return f?-x:x;
}
inline void ot(int x){
if(x<0) putchar('-'),x=-x;
if(x>9) ot(x/10);putchar(x%10|48);
}
struct Card{
int id;
char type;
};
inline bool operator<(const Card &A,const Card &B){
return A.id<B.id;
}
int n,m,tot;
int pre[maxn],nextt[maxn];
int card_num[maxn];
int HP[maxn];
set<Card> card[maxn];
int type[maxn],tot3;
char s[maxn];
char card_heap[2010];
bool running=true;
bool show[maxn],dead_pig[maxn],show2[maxn];
bool equip[maxn];
bool used_K[maxn];
inline void CT(char c){
if(c=='P') printf("桃");
if(c=='K') printf("杀");
if(c=='D') printf("闪");
if(c=='F') printf("决斗");
if(c=='N') printf("南猪入侵");
if(c=='W') printf("万箭齐发");
if(c=='J') printf("无懈可击");
if(c=='Z') printf("猪哥连弩");
}
inline void TYPE(int id){
id=type[id];
if(id==1) printf("主猪");
if(id==2) printf("忠猪");
if(id==3) printf("反猪");
}
inline void happy(){
int d=rand()%15;
switch(d){
case 0:cout<<"在覆灭蒋家王朝的哈哈大笑声中";break;
case 1:cout<<"轻描淡写地";break;
case 2:cout<<"冷笑一声";break;
case 3:cout<<"极不情愿地";break;
case 4:cout<<"使用七颗龙珠召唤并";break;
case 5:cout<<"眼中三分轻蔑四分凉薄三分漫不经心地";break;
case 6:cout<<"语无伦次地";break;
case 7:cout<<"亟不可待地";break;
case 8:cout<<"破口大骂地";break;
case 9:cout<<"仰天哀嚎地";break;
case 10:cout<<"不知道该说什么地";break;
case 11:cout<<"小心翼翼地";break;
case 12:cout<<"在真理指引下";break;
case 13:cout<<"反手";break;
case 14:cout<<"大惊失色地";break;
}
}
inline void use(int id,char c,int id2=0){
if(!id2) TYPE(id),cout<<id,happy(),cout<<"使用了",CT(c),el;
else TYPE(id),cout<<id<<"对",TYPE(id2),cout<<id2,happy(),cout<<"使用了",CT(c),el;
}
inline void discard(int id,char c){
TYPE(id),cout<<id,happy(),cout<<"弃置了",CT(c),el;
}
void init(){
n=tot=read(),m=read();
for(Re i=1;i<=n;++i){
HP[i]=4;
cin>>s+1;
switch(s[1]){
case 'M':type[i]=1;break;
case 'Z':type[i]=2;break;
case 'F':type[i]=3,tot3++;break;
}
for(Re j=1;j<=4;++j){
cin>>s+1;
card[i].insert(Card{++card_num[i],s[1]});
}
}
for(Re i=1;i<=n;++i) pre[i]=i-1,nextt[i]=i+1;
pre[1]=n,nextt[n]=1;
for(Re i=1;i<=m;++i){
cin>>s+1;
card_heap[m+1-i]=s[1];
}
show[1]=true;
}
inline void get_card(int id){
if(!m) m++;
TYPE(id),cout<<id,happy(),cout<<"得到一张",CT(card_heap[m]),el;
card[id].insert(Card{++card_num[id],card_heap[m--]});
}
inline bool check(int id,char tp){
for(auto x:card[id])
if(x.type==tp)
return true;
return false;
}
inline void erase(int id,char tp){
for(auto x:card[id])
if(x.type==tp) {
card[id].erase(x);
return;
}
}
inline bool same_type(int id1,int id2){
if(type[id1]<=2&&type[id2]<=2) return true;
if(type[id1]+type[id2]==6) return true;
return false;
}
inline bool good(int id1,int id2){
if(!show[id2]) return false;
return same_type(id1,id2);
}
inline bool bad(int id1,int id2){
if(!show[id2]){
if(id1==1&&show2[id2]) return true;
return false;
}
return same_type(id1,id2)==false;
}
inline void use_peach(int now){
HP[now]++;
use(now,'P');
TYPE(now),cout<<now,happy(),cout<<"HP++"<<endl;
TYPE(now),cout<<now<<"的血量为"<<HP[now]<<endl;
erase(now,'P');
}
inline void dead(int id1,int id2){
if(check(id2,'P')){
use_peach(id2);
return;
}
tot--;
TYPE(id1),cout<<id1,happy(),cout<<"kill",TYPE(id2),cout<<id2<<endl;
dead_pig[id2]=true;
if(id2==1) running=false;
if(type[id2]==3){
tot3--;
if(!tot3) running=false;
}
if(!running) return;
if(type[id2]==3){
get_card(id1);
get_card(id1);
get_card(id1);
}
if(type[id2]==2&&type[id1]==1){
TYPE(id1),cout<<id1,happy(),cout<<"失去所有手牌"<<endl;
card[id1].clear();
if(equip[id1]){
TYPE(id1),cout<<id1,happy(),cout<<"失去装备牌"<<endl;
equip[id1]=false;
}
}
int pr=pre[id2],ne=nextt[id2];
nextt[pr]=ne;
pre[ne]=pr;
}
inline void HP_down(int id1,int id2){
HP[id2]--;
if(id2==1) show2[id1]=true;
TYPE(id2),cout<<id2,happy(),cout<<"HP--"<<endl;
TYPE(id2),cout<<id2<<"的血量为"<<HP[id2]<<endl;
if(!HP[id2]) dead(id1,id2);
}
bool flawless(int id,int p,int opt){
bool ju=false;
int d=tot;
while(d--){
if(opt==1&&good(p,id)&&check(p,'J')){
show[p]=true;
use(p,'J',id);
erase(p,'J');
return flawless(id,nextt[p],opt^1)==false;
}
if(opt==0&&bad(p,id)&&check(p,'J')){
show[p]=true;
use(p,'J',id);
erase(p,'J');
return flawless(id,nextt[p],opt^1)==false;
}
p=nextt[p];
}
return false;
}
inline void Barbarian_breakout(int now){
int p=nextt[now];
while(p!=now&&running){
if(flawless(p,now,1)){
p=nextt[p];
continue;
}
if(check(p,'K')){
erase(p,'K');
discard(p,'K');
p=nextt[p];
continue;
}
HP_down(now,p);
p=nextt[p];
}
}
inline void Triple_arrow(int now){
int p=nextt[now];
while(p!=now&&running){
if(flawless(p,now,1)){
p=nextt[p];
continue;
}
if(check(p,'D')){
erase(p,'D');
discard(p,'D');
p=nextt[p];
continue;
}
HP_down(now,p);
p=nextt[p];
}
}
inline void Kill(int id1,int id2){
show[id1]=true;
if(check(id2,'D')){
use(id2,'D');
erase(id2,'D');
return;
}
HP_down(id1,id2);
}
inline int find_bad(int now){
if(type[now]==3) return 1;
int p=nextt[now];
while(p^now){
if(bad(now,p)) return p;
p=nextt[p];
}
return 0;
}
inline void duel(int id1,int id2){
show[id1]=true;
if(flawless(id2,nextt[id1],1)) return;
while(1){
if(id1==1&&type[id2]==2){
HP_down(id1,id2);
return;
}
if(check(id2,'K')){
discard(id2,'K');
erase(id2,'K');
}
else{
HP_down(id1,id2);
return;
}
if(check(id1,'K')){
discard(id1,'K');
erase(id1,'K');
}
else{
HP_down(id2,id1);
return;
}
}
}
void play(){
int now=1;
while(running){
cout<<"到了",TYPE(now),cout<<now<<"的回合"<<endl;
get_card(now);
get_card(now);
while(HP[now]&&running){
bool ju=false;
for(auto x:card[now]){
if(HP[now]==0||running==false) break;
int Tp=x.type;
if(Tp=='P'&&HP[now]!=4){
use_peach(now);
ju=true;
}
else if(Tp=='N'){
use(now,'N');
erase(now,'N');
Barbarian_breakout(now);
ju=true;
}
else if(Tp=='W'){
use(now,'W');
erase(now,'W');
Triple_arrow(now);
ju=true;
}
else if(Tp=='Z'){
if(equip[now]) discard(now,'Z');
use(now,'Z');
erase(now,'Z');
equip[now]=true;
used_K[now]=false;
ju=true;
}
else if(Tp=='K'&&used_K[now]==false&&bad(now,nextt[now])){
if(!equip[now]) used_K[now]=true;
use(now,'K',nextt[now]);
erase(now,'K');
Kill(now,nextt[now]);
ju=true;
}
else if(Tp=='F'&&find_bad(now)){
use(now,'F',find_bad(now));
erase(now,'F');
duel(now,find_bad(now));
ju=true;
}
if(ju) break;
}
if(!ju) break;
}
used_K[now]=false;
if(!running) return;
now=nextt[now];
cout<<endl;
}
}
void print(){
if(dead_pig[1]) puts("FP");
else puts("MP");
for(Re i=1;i<=n;++i)
if(dead_pig[i]) puts("DEAD");
else{
for(auto x:card[i])
putchar(x.type),_;
el;
}
}
Sakura main(){
srand(time(0));
init();
play();
print();
}
经过
1.不知道主猪打类反 主忠反三猪谁也不打谁 一人猪摸了十万张闪 把我系统栈摸爆了
2.忘了决斗是出牌的后出杀 然后主猪有四张决斗 然后就没有然后了
3.反猪7杀了反猪5后反猪5摸了三张牌 然后反猪7杀了反猪7自摸三张
(揭馆而起)
4.因为\(continue\)时忘跳链表 所以只要南猪入侵和万箭齐发时这个猪不掉血就不过去(恼)
表面上看就是几个忠猪对着主猪用了1mol无懈
注意
1.无懈可击始终是从锦囊牌发出者开始判定(包括自己)
2.单体攻击牌一定跳身份
3.除无懈可击判定外南猪入侵和万箭齐发不能按次数循环 因为删掉自己之后次数会改变
4.每使用一张牌之后都要从头开始找能使用的牌 比如$ K Z K $的情况
标签:猪国,int,反猪,maxn,printf,id,card From: https://www.cnblogs.com/Sakura-Lu/p/16754496.html