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;
}
原创文章 99 获赞 15 访问量 7349

猜你喜欢

转载自blog.csdn.net/qq_45328552/article/details/102225365