URAL 1804 The Machinegunners in a Playoff(模拟比赛得分)

本文深入探讨了游戏开发领域的核心技术,包括游戏引擎、图形渲染、3D空间视频等关键概念及应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1804. The Machinegunners in a Playoff

Time limit: 0.5 second
Memory limit: 64 MB
The Machinegunners women's football team has advanced to the knockout stage of the Revolution Cup. The Cavalry team is their opponent in the first round.
According to the rules, the teams must play two games, one at the Machinegunners' stadium and the other at the Cavalry's stadium. The team that scores more goals in the two games will advance to the next round. If the teams score the same number of goals, then the team that scores more goals at the opponent's stadium will advance. If these numbers are also the same, then the winner will be chosen at random.
The teams have played their first game already. The Machinegunners want to work out an adequate tactics for the return game, and for this they need to know the following two values:
  • the minimal number of goals they must score to get a chance to advance to the next round;
  • the maximal number of goals they may score which leaves a chance for their opponents to advance to the next round.
It is known that no team can score more than thirty goals in one game.

Input

The input consists of several test cases. The first line contains the number of test cases t (1 ≤ t≤ 200). Each of the following t lines describes one test case and contains the result of the first game in the form:
The Machinegunners played where game, scored x goals, and conceded y goals.
where where is the string “home” or “away”; 0 ≤ xy ≤ 30.

Output

For each of test cases output in a separate line the minimal number of goals necessary to advance to the next round and the maximal number of goals that does not guarantee this.

Sample

input output
2
The Machinegunners played home game, scored 28 goals, and conceded 0 goals.
The Machinegunners played home game, scored 1 goals, and conceded 1 goals.
0 1
1 29

题意:

判断让自己赢的最小的自己的得分和让对方赢得的自己的最大得分,如果总得分情况一样,就看客场得分的情况。

AC代码:

#include <cstdio>
#include <iostream>
using namespace std;
int main(){
	int t,x,y,flag,i;
	char a[152];
	scanf("%d",&t);
	getchar();
	while(t--){
		cin.getline(a,150);
		flag=1;
		for(i=43;i<150;i++){
			if(a[i]>='0'&&a[i]<='9'){
				if(flag){
					x=a[i]-'0';
					if(a[i+1]>='0'&&a[i+1]<='9'){
						x=x*10+a[i+1]-'0';
							i++;
					}
					flag=0;
				}
				else{
					y=a[i]-'0';
					if(a[i+1]>='0'&&a[i+1]<='9')
						y=y*10+a[i+1]-'0';
					break;
				}
			}
		}
		if(a[26]=='h'){
			if(x==0){
				if(y==0)
					printf("0 29\n");
				else
					printf("%d 30\n",y);
			}
			else if(x==30){
				if(y==30)
					printf("1 30\n");
				else
					printf("0 %d\n",y);
			}
			else{
				if(x==y)
					printf("1 29\n");
				else if(x<y)
					printf("%d 30\n",y-x+1);
				else
					printf("0 %d\n",30+y-x-1);
			}
		}
		else if(a[26]=='a'){
			if(x==y)
				printf("0 30\n");
			else if(x<y)
				printf("%d 30\n",y-x);
			else
				printf("0 %d\n",30+y-x);
		}
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值