比赛 20110928 评测结果 C
题目名称 拱猪计分 最终得分 0
用户昵称 Makazeu 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-09-28 20:00:46
显示代码纯文本
#include <cstdio>
#include <iostream>
using namespace std;

class PIG
{
public:
	short int total;
	bool S;
	bool D;
	bool C;
	bool H[14];
	int score;
	void pre()
	{
		total=0;
		S=false;
		D=false;
		C=false;
		memset(H,false,sizeof(H));
		score=0;
	}
}P[5];

bool red(int k)
{
	for (int i=1;i<=13;i++)
		if (!P[k].H[i]) return false;
	return true;
}

int GetRed(int k)
{
	int s=0;

	if (P[k].H[1]) s-=50;
	if (P[k].H[2]) s-=2;
	if (P[k].H[3]) s-=3;
	
	if (P[k].H[4]) s-=4;
	if (P[k].H[5]) s-=5;
	if (P[k].H[6]) s-=6;
	
	if (P[k].H[7]) s-=7;
	if (P[k].H[8]) s-=8;
	if (P[k].H[9]) s-=9;
	
	if (P[k].H[10]) s-=10;
	
	if (P[k].H[11]) s-=20;
	if (P[k].H[12]) s-=30;
	if (P[k].H[13]) s-=40;
	return s;
}

void compute(int k)
{
	if (P[k].total==0) {cout<<0; return;}
	
	if (P[k].total==1 && P[k].C) {cout<<"+50"; return;}
	
	if (P[k].total==13 && red(k)) {cout<<"+200"; return;}
	
	if (red(k))
	{
		int s=200;
		if (P[k].S && P[k].D) s=500;
		if (P[k].S && !P[k].D) s-=100;
		if (!P[k].S && P[k].D) s+=100;
		if (P[k].C) s*=2;
		
		cout<<"+"<<s;
		return;
	}
	
	if (!red(k))
	{
		int s=GetRed(k);
		if (P[k].S && !P[k].D) s-=100;
		if (!P[k].S && P[k].D) s+=100;
		if (P[k].C) s*=2;
		
		if (s>0) cout<<"+"<<s;
		if (s==0) cout<<0;
		if (s<0) cout<<s;
	}
}

void init()
{
	short int num[5];
	char C;
	short int pai;
	while (! cin.eof())
	{
		for (int k=1;k<=4;k++)
		{
			P[k].pre();
			cin>>num[k];
			for (int i=1;i<=num[k];i++)
			{
				cin>>C>>pai;
				if (C=='H') {P[k].H[pai]=true; P[k].total++; continue;}
				if (C=='S' && pai==12) {P[k].S=true; P[k].total++; continue;}
				if (C=='D' && pai==11) {P[k].D=true; P[k].total++; continue;}
				if (C=='C' && pai==10) {P[k].C=true; P[k].total++; continue;}
			}
		}
		if (num[1]==0 && num[2]==0 && num[3]==0 && num[4]==0) return;
		
		for (int i=1;i<=4;i++)
		{
			compute(i);
			if (i<4) cout<<" ";
			if (i==4) cout<<endl;
		} 
	}
}

int main()
{
	freopen("heart.in","r",stdin);
	freopen("heart.out","w",stdout);
	init();
	return 0;
}