San Guo Sha

Problem Description
San Guo Sha is a popular Board Game. There are four kinds of cards: identity, role, life and magic card. Today we just regard the identity cards. There are four kinds of identity: Lord(ZG), Loyal minister(ZC), Provocateur(NJ) and Rebel(FZ). To win the game Lord and Loyal minister 's goal is make all of Provocateur and rebel dead, Rebel's goal is make Lord dead, Provocateur's goal is to be the last survivor. If Load dead and there's only one Provocateur then he wins (just one Provocateur win), others Rebels win.
 In the standard contest, there are score rule:(If you know Chinese, could see the second picture)
San Guo Sha_第1张图片
The last score equal basic score plus extra score. Now I will tell the identity of everyone and who killed who, please compute everyone' last score.
 

Input
On the first line of input is a single positive integer, 1<=T<=100, specifying the number of test cases to follow.
Each test case begins with 2 integers N , M (4<=N<=100, 0<=MThen N string on next line("ZG","ZC","FZ","NJ"), specifying each's identity(begin with 0). I promise each identity will be at least one and there is one and only one ZG.
Then M lines follow, each line with two numbers A B, meaning A killed B.I promise A and B must alive player. If someone was win then you should not deal with the remain instruct.
 

Output
Please output the everyone's last score in a line, n integers separate by a empty.
 

Sample Input
 
    
3 4 3 ZG ZC NJ FZ 1 3 2 1 0 2 6 1 ZG ZC NJ FZ FZ FZ 3 0 8 7 ZG ZC ZC NJ NJ FZ FZ FZ 3 1 3 2 3 4 3 5 3 6 3 7 3 0
 

Sample Output
 
    
5 6 4 0 0 0 1 11 9 9 1 0 0 20 0 0 0 0
 
太欺负人了,第一欺负姐姐没玩儿过三国杀,第二欺负姐姐不懂什么叫“单挑!”
所谓“单挑”,就是说——必须有一个主公,忠臣有没有无所谓,内奸一个,没有反贼!
害我WA了不知道多少次!心痛……
#include #include using namespace std; #define zg 1 #define zc 2 #define fz 3 #define nj 4 struct person { int score; int mode; bool isalive; int killedby; int isdantiao; }node[110]; int num[5]; int win; int a,b,flag; int m,n,j,k,t,temp; void init() { string str; flag=0; int i,j; scanf("%d%d",&m,&n); win=0; memset(num,0,sizeof(num)); for(i=0;i<110;i++) { node[i].isalive=1; node[i].killedby=0; node[i].mode=0; node[i].score=0; node[i].isdantiao=0; } for(i=0;i>str; if(str=="ZG") { num[zg]++; node[i].mode=zg; node[i].isalive=1; node[i].score=0; } if(str=="ZC") { num[zc]++; node[i].mode=zc; node[i].isalive=1; node[i].score=0; } if(str=="FZ") { num[fz]++; node[i].mode=fz; node[i].isalive=1; node[i].score=0; } if(str=="NJ") { num[nj]++; node[i].mode=nj; node[i].isalive=1; node[i].score=0; } } for(j=0;j
 

你可能感兴趣的:(ACM)