有的时候还会3221225477(RE)。。。
本shabi已AFO一年半,觉得sha勿喷。
这里有记录+源码。
只用调到10分
源码:
#include <bits/stdc++.h>
using namespace std;
int n, m, fpn;
bool game_continue = 1;
queue<char> cards;
struct pig
{
int type;
int cdsn;
char cds[2005];
int life = 4;
int pubtype;
bool fplike;
bool z;
int prev;
int next;
}pigs[12];
void getcards(int p, int cnt)
{
for(int i = 0; i < cnt; i ++)
{
if(cards.front() == 'Z')
{
pigs[p].z = 1;
continue;
}
pigs[p].cds[pigs[p].cdsn + 1] = cards.front();
cards.pop();
pigs[p].cdsn ++;
}
}
bool usecard(int p, char card)
{
for(int i = 1; i <= pigs[p].cdsn; i ++)
{
if(pigs[p].cds[i] == card)
{
pigs[p].cds[i] = '\0';
pigs[p].cdsn --;
return 1;
}
}
return 0;
}
bool badrelation(int p1, int p2)
{
if(pigs[p1].pubtype == 0) return 0;
if(pigs[p1].pubtype == 1 && pigs[p2].pubtype == 2) return 1;
if(pigs[p1].pubtype == 2 && pigs[p2].pubtype == 1) return 1;
if(pigs[p1].type == 0 && pigs[p2].fplike) return 1;
return 0;
}
bool goodrelation(int p1, int p2)
{
if(pigs[p1].pubtype == 0) return 0;
if(pigs[p1].pubtype == 1 && pigs[p2].pubtype == 1) return 1;
if(pigs[p1].pubtype == 2 && pigs[p2].pubtype == 2) return 1;
return 0;
}
void getfeud(int p1, int p2)
{
if(pigs[p2].pubtype == 0) return ;
if(pigs[p2].pubtype == 1) pigs[p1].pubtype = 2;
if(pigs[p2].pubtype == 2) pigs[p1].pubtype = 1;
}
void ingratiate(int p1, int p2)
{
if(pigs[p2].pubtype == 0) return ;
if(pigs[p2].pubtype == 1) pigs[p1].pubtype = 1;
if(pigs[p2].pubtype == 2) pigs[p1].pubtype = 2;
}
void damage(int vic, int klr)
{
pigs[vic].life --;
while(pigs[vic].life <= 0 && usecard(vic, 'P'))
{
pigs[vic].life ++;
}
if(pigs[vic].life <= 0)
{
for(int i = 1; i <= pigs[vic].cdsn; i ++)
{
pigs[vic].cds[i] = '\0';
}
pigs[vic].cdsn = 0;
pigs[vic].z = 0;
if(pigs[vic].type == 0)
{
game_continue = 0;
return ;
}
else if(pigs[vic].type == 1)
{
if(pigs[klr].type == 0)
{
for(int i = 1; i <= pigs[klr].cdsn; i ++)
{
pigs[klr].cds[i] = '\0';
}
pigs[klr].cdsn = 0;
pigs[klr].z = 0;
}
}
else if(pigs[vic].type == 3)
{
fpn --;
if(fpn == 0)
{
game_continue = 0;
return ;
}
getcards(klr, 3);
}
pigs[pigs[vic].prev].next = pigs[vic].next;
pigs[pigs[vic].next].prev = pigs[vic].prev;
}
}
void K(int user, int rcvr)
{
getfeud(user, rcvr);
if(usecard(rcvr, 'D')) damage(rcvr, user);
}
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; i ++)
{
string tmp;
cin >> tmp >> pigs[i].cds;
if(tmp == "MP") pigs[i].type = 0;
else if(tmp == "ZP") pigs[i].type = 1;
else
{
pigs[i].type = 3;
fpn ++;
}
pigs[i].prev = i - 1;
pigs[i].next = i + 1;
}
for(int i = 1; i <= m; i ++)
{
char tmp;
cin >> tmp;
cards.push(tmp);
}
while(game_continue)
{
for(int i = 1; i <= n; i ++)
{
if(pigs[i].life <= 0) continue;
getcards(i, 2);
if(pigs[i].life < 4) usecard(i, 'P');
if(pigs[i].type == 0)
{
if(pigs[pigs[i].next].pubtype == 2)
{
if(pigs[i].z)
{
while(usecard(i, 'K'))
{
K(i, pigs[i].next);
}
}
else
{
usecard(i, 'K');
K(i, pigs[i].next);
}
}
}
else if(pigs[i].type == 1)
{
if(pigs[pigs[i].next].pubtype == 2)
{
if(pigs[i].z)
{
while(usecard(i, 'K'))
{
K(i, pigs[i].next);
}
}
else
{
usecard(i, 'K');
K(i, pigs[i].next);
}
}
}
else if(pigs[i].type == 2)
{
if(pigs[pigs[i].next].type == 0 || pigs[pigs[i].next].pubtype == 1)
{
if(pigs[i].z)
{
while(usecard(i, 'K'))
{
K(i, pigs[i].next);
}
}
else
{
usecard(i, 'K');
K(i, pigs[i].next);
}
}
}
}
}
if(pigs[1].life <= 0) cout << "FP\n";
else cout << "MP\n";
for(int i = 1; i <= n; i ++)
{
if(pigs[i].life <= 0)
{
cout << "DEAD\n";
continue;
}
for(int j = 1; j <= pigs[i].cdsn; j ++)
{
if(pigs[i].cds[j] != '\0' && j != pigs[i].cdsn) cout << pigs[i].cds[j] << " ";
else if(j == pigs[i].cdsn) cout << pigs[i].cds[j];
}
cout << "\n";
}
return 0;
}