Problem L. World Cup(模拟+暴力)

传送门

题解:

运用6重循环对6场比赛进行模拟,把结果存起来,如果出现1次,输出“YES”,如果出现2次及以上输出“NO”,如果一次都没出现,输出“Wrong Scoreboard”。

#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int vis[11][11][11][11];//存每种比赛结果出现次数

int main()
{
//	freopen("input.txt","r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int score_p1[3]={3,0,1};
	int score_p2[3]={0,3,1};//score_p1数组中的结果对应score_p2数组中的结果
	for(int ab=0;ab<3;ab++)
		for(int ac=0;ac<3;ac++)
			for(int ad=0;ad<3;ad++)	
				for(int bc=0;bc<3;bc++)
					for(int bd=0;bd<3;bd++)
						for(int cd=0;cd<3;cd++)
						{
							int sa=score_p1[ab]+score_p1[ac]+score_p1[ad];
							int sb=score_p2[ab]+score_p1[bc]+score_p1[bd];
							int sc=score_p2[ac]+score_p2[bc]+score_p1[cd];
							int sd=score_p2[ad]+score_p2[bd]+score_p2[cd];
							vis[sa][sb][sc][sd]++;
						}
	int t;
	cin>>t;
	int th=1;
	while(t--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(vis[a][b][c][d]==0) cout<<"Case #"<<th<<": Wrong Scoreboard"<<endl;
		if(vis[a][b][c][d]==1) cout<<"Case #"<<th<<": Yes"<<endl;
		if(vis[a][b][c][d]>=2) cout<<"Case #"<<th<<": No"<<endl;
		th++;
	}
	
	
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值