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


    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个骰子,两人均已知各骰子的点数,然后开始一个人声明,另一个人提出挑战,问最终谁赢。

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

    具体代码如下:

    1. #include
    2. #include
    3. #include
    4. #include
    5. #include
    6. #include
    7. using namespace std;
    8. bool vis[10];
    9. signed main()
    10. {
    11. int T;
    12. cin >> T;
    13. while(T--){
    14. int n;
    15. scanf("%d", &n);
    16. bool flag1 = false, flag2 = false;
    17. for(int i = 1; i <= 6; i++)
    18. vis[i] = false;
    19. for(int i = 1; i <= n; i++){
    20. int t;
    21. scanf("%d", &t);
    22. if(vis[t]) flag1 = true;
    23. vis[t] = true;
    24. }
    25. for(int i = 1; i <= 6; i++)
    26. vis[i] = false;
    27. for(int i = 1; i <= n; i++){
    28. int t;
    29. scanf("%d", &t);
    30. if(vis[t]) flag2 = true;
    31. vis[t] = true;
    32. }
    33. if(flag1 || flag2) puts("Win!");
    34. else puts("Just a game of chance.");
    35. }
    36. return 0;
    37. }

     

  • 相关阅读:
    树--搜索二叉树
    流密码:线性同余生成器 LCG
    基本排序算法的总结笔记
    BJFU|计算机网络缩写对照表
    txt文件恢复如何操作?详细图文教程
    计算机操作系统笔记总结
    【iOS ARKit】网络传输 ARWorldMap
    juc继承图片
    01-Java的static关键字、单例、代码块、继承
    NLog详解
  • 原文地址:https://blog.csdn.net/m0_55982600/article/details/126153503