[博弈论][思维]Bragging Dice 2022杭电多校第5场 1010

59 篇文章 0 订阅
6 篇文章 0 订阅

Problem Description

In the mysterious accient East, there is an ancient dice game - "bragging". Now YahAHa and Peanut is playing bragging.

The rules of the game are as follows:

There are 22 players in one game. Each player has nn dices in the cup. Both players roll the dice once.

Players play in turns. YahAHa start. In the first turn, YahAHa can claim "there are x(x\geq 1)x(x≥1) dices with y(1\leq y\leq 6)y(1≤y≤6) points in the 2 cups".

Then Peanut has 22 choices.

  1. Challenge YahAHa. If anyone challenges, the game is over . Each player opens its cup. If indeed there are xx dices with yy points in the cups, YahAHa wins, otherwise Peanut wins.

  2. Continue to claim, but can only claim "there are x_1x1​ (x_1>x)(x1​>x) dices with y_1(1\leq y_1\leq 6)y1​(1≤y1​≤6) points in the cups" or "there are x_2x2​ (x_2=x)(x2​=x) dices with y_2y2​ (y_2 > y)(y2​>y) points in the cups".

After Peanut claimed, YahAHa continued to choose whether to challenge or claim. Both players take turns until someone challenges, then the game is over.

To make the game more interesting, here are some special rules.

  1. If no one has claimed that "there are xx dices with 11 point in the cups", the dice with 11 point can be regarded as any points of dice.

  2. If all dices in one cup has the same points, it's considered there is an extra dice with the same points. For example, if there are 55 dices and 55 dices are all with 66 points, it's considered there are 66 dices with 66 points.

  3. If each dice in one cup has different points, it's considered "there are 00 dice with any points in the cup". For example, if there are 55 dices,their points are 11 point, 22 points, 33 points, 44 points and 55 points. It's considered "there are 00 dice with 11 point in the cup", "there are 00 dice with 22 point in the cup", ... , "there are 00 dice with 55 point in the cup".

If there is conflict in these three rules, please consider the third special rule first.

YahAHa and Peanut don't like stupid game of chance, so they want to play this game while knowing the points of every dices in the 2 cups.

Given you the points of all dices they roll. YahAHa wants to find out who will win the game if both of them play the game optimally.

Input

Each test contains multiple test cases. The first line contains the number of test cases (1 \le T \le 30)(1≤T≤30). Description of the test cases follows.

The first line of the input contains only one integers nn (2\le n \le 2\times 10^5)(2≤n≤2×105) indicating the number of dices.

The next line contains nn integers a_1, a_2, \cdots, a_na1​,a2​,⋯,an​. The ii-th integer a_iai​ indicating the points of the ii-th dice from YahAHa.

The next line contains nn integers b_1, b_2, \cdots, b_nb1​,b2​,⋯,bn​. The ii-th integer b_ibi​ indicating the points of the ii-th dice from Peanut.

Output

For each test case:

If YahAHa wins, print "Win!" in one line; If Peanut wins, print "Just a game of chance." in one line.

Sample Input

1

5

4 6 4 1 2

3 6 6 2 3

Sample Output

Win!

题意: 有两个人玩游戏,桌子上有两个杯子,每个杯子中有n个骰子,两人均已知各骰子的点数,然后开始一个人声明,另一个人提出挑战,问最终谁赢。

分析: 由于二人都知道所有骰子点数了,那么先手的人为了赢一定会说个数最多且点数最大的骰子,这样后手的人一定会输,不过由于这个游戏还包括三条特殊规则,所以先手并不是必胜,前两条规则没什么用,第三条规则是如果某个杯子中点数均不同,那么该杯子中视为没有骰子。如果两个杯子中都是这样,那么最终桌子上就没有骰子了,所以先手就没法声明了,此时先手会输。

具体代码如下:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
using namespace std;

bool vis[10];

signed main()
{
	int T;
	cin >> T;
	while(T--){
		int n;
		scanf("%d", &n);
		bool flag1 = false, flag2 = false;
		for(int i = 1; i <= 6; i++)
			vis[i] = false;
		for(int i = 1; i <= n; i++){
			int t;
			scanf("%d", &t);
			if(vis[t]) flag1 = true;
			vis[t] = true;
		}
		for(int i = 1; i <= 6; i++)
			vis[i] = false;
		for(int i = 1; i <= n; i++){
			int t;
			scanf("%d", &t);
			if(vis[t]) flag2 = true;
			vis[t] = true;
		}
		if(flag1 || flag2) puts("Win!");
		else puts("Just a game of chance.");
	} 
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值