这个题。。。。trick挺多。。。
1.中途可能一队踢完另一对就不用踢了,
2.五球以内的判断
3.最后可能平局的说。。。。
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
int t,team1,team2;
struct rec
{
char s[5][5];
}player[3][21];
void clear()
{
memset(player,0,sizeof(player));
team1=0;
team2=0;
}
void Input()
{
for (int i=1;i<=11;i++)
{
scanf("%s ",player[1][i].s[1]);
scanf("%s ",player[1][i].s[2]);
scanf("%s ",player[1][i].s[3]);
}
for (int i=1;i<=11;i++)
{
scanf("%s ",player[2][i].s[1]);
scanf("%s ",player[2][i].s[2]);
scanf("%s ",player[2][i].s[3]);
}
}
void work()
{
for (int i=1;i<=3;i++)
for (int j=1;j<=11;j++)
{
if (player[1][j].s[i][0]=='y') team1++;
if ((i-1)*11+j<=5)
{
if (team1>team2+5-j+1) return;
if (team2>team1+5-j) return;
}
if (player[2][j].s[i][0]=='y') team2++;
if ((i-1)*11+j<=5)
{
if (team1>team2+5-j) return;
if (team2>team1+5-j) return;
}
if ((i-1)*11+j>5)
{
if (team1>team2) return;
if (team2>team1) return;
}
}
}
void output(int x)
{
printf("Match %d:\n",x);
if (team1>team2) printf("Winner: home\n");
else printf("Winner: away\n");
printf("Score: %d:%d\n",team1,team2);
}
int main()
{
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
scanf("%d ",&t);
for (int i=1;i<=t;i++)
{
clear();
Input();
work();
output(i);
}
}