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

#define I_F "heart.in"
#define O_F "heart.out"

const short H[13]={-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40};

std::ifstream fin(I_F);
std::ofstream fout(O_F);

struct card
{
	short x,y;
};
short c[4];
card s[4][52];
int score[4];

void Input();
void Search();
void Output();

int main()
{
	Input();
	while (c[0]+c[1]+c[2]+c[3]>0)
	{
		Search();
		Output();
		Input();
	}
	fin.close();
	fout.close();
	return 0;
}

void Input()
{
	std::string t;
	for (short i=0; i<4; i++)
	{
		fin>>c[i];
		for (short j=0; j<c[i]; j++)
		{
			fin>>t;
			if (t[0]=='S')
				s[i][j].x=0;
			else if (t[0]=='H')
				s[i][j].x=1;
			else if (t[0]=='D')
				s[i][j].x=2;
			else
				s[i][j].x=3;
			s[i][j].y=((t.length()<3)?((char)t[1]-'0'):(((char)t[1]-'0')*10+(char)t[2]-'0'))-1;
		}
	}
}

void Search()
{
	score[0]=score[1]=score[2]=score[3]=score[4]=0;
	short h;
	bool fs, fc, fd, f;
	for (short i=0; i<4; i++)
	{
		h=0;
		fs=fc=fd=f=false;
		for (short j=0; j<c[i]; j++)
			if (s[i][j].x==1)
			{
				score[i]+=H[s[i][j].y];
				h++;
				f=true;
			}
			else if ((s[i][j].x==0)&&(s[i][j].y==11))
				score[i]-=100,
				fs=f=true;
			else if ((s[i][j].x==2)&&(s[i][j].y==10))
				score[i]+=100,
				fd=f=true;
			else if ((s[i][j].x==3)&&(s[i][j].y==9))
				fc=true;
		if (h==13)
		{
			score[i]+=394;
			if (fs && fd)
				score[i]=500;
		}
		if (fc)
		{
			if (f)
				score[i]*=2;
			else
				score[i]=50;
		}
	}
}

void Output()
{
	for (short i=0; i<4; i++)
	{
		if (score[i]>0)
			fout<<'+';
		fout<<score[i]<<' ';
	}
	fout<<std::endl;
}