Georgia and Bob 格鲁吉亚和鲍勃

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 13319 Accepted: 4461
时间限制: 1000MS 内存限制: 10000K
提交总数: 13319 接受: 4461

Description 描述

Georgia and Bob decide to play a self-invented game.
格鲁吉亚和鲍勃决定玩自己发明的游戏。
They draw a row of grids on paper, number the grids from left to right by 1, 2, 3, …, and place N chessmen on different grids, as shown in the following figure for example:
他们在纸上绘制一排网格,将网格从左到右依次为1,2,3,…,并将N个西洋棋棋子放在不同的网格上,如下图所示:

Georgia and Bob move the chessmen in turn.
格鲁吉亚和鲍勃依次移动西洋棋棋子。
Every time a player will choose a chessman, and move it to the left without going over any other chessmen or across the left edge.
每次玩家选择一个棋子,并将其移动到左边而不越过任何其他西洋棋棋子或横跨左边缘。
The player can freely choose number of steps the chessman moves, with the constraint that the chessman must be moved at least ONE step and one grid can at most contains ONE single chessman.
玩家可以自由选择棋子移动的步数,其限制是棋子必须至少移动一步,一个网格最多可以包含一个棋子。
The player who cannot make a move loses the game.
无法移动的玩家将失去游戏。

Georgia always plays first since “Lady first”.
自“女士第一”以来,格鲁吉亚总是首发。
Suppose that Georgia and Bob both do their best in the game, i.e., if one of them knows a way to win the game, he or she will be able to carry it out.
假设格鲁吉亚和鲍勃都在比赛中尽了最大努力,也就是说,如果他们中的一个知道如何赢得比赛,那么他或她将能够实现这一目标。

Given the initial positions of the n chessmen, can you predict who will finally win the game?
鉴于n个西洋棋棋子的初始位置,你能预测谁将最终赢得比赛吗?

Input 输入

The first line of the input contains a single integer T (1 <= T <= 20), the number of test cases.
输入的第一行包含单个整数T(1 <= T <= 20),即测试用例的数量。
Then T cases follow.
然后是T案例。
Each test case contains two lines.
每个测试用例包含两行。
The first line consists of one integer N (1 <= N <= 1000), indicating the number of chessmen.
第一行由一个整数N(1 <= N <= 1000)组成,表示西洋棋棋子的数量。
The second line contains N different integers P1, P2 … Pn (1 <= Pi <= 10000), which are the initial positions of the n chessmen.
第二行包含N个不同的整数P1,P2 … Pn(1 <= Pi <= 10000),它们是n个西洋棋棋子的初始位置。

Output 输出

For each test case, prints a single line, “Georgia will win”, if Georgia will win the game; “Bob will win”, if Bob will win the game; otherwise ‘Not sure’.
对于每个测试案例,如果格鲁吉亚将赢得比赛,则打印一行“格鲁吉亚将获胜”; 如果鲍勃将赢得比赛,“鲍勃会赢” 否则’不确定’。

Sample Input 样例输入

2
3
1 2 3
8
1 5 6 7 9 12 14 17

Sample Output 样例输出

Bob will win
Georgia will win

Code

#include <algorithm>
#include <iostream>
#include <cstring>using namespace std;
string ans[1000];
int t, n, p[1000];string deal(int pInt[],int n) {std::sort(pInt, pInt + n);int result = 0;if ((n & 1) == 1)for (int i = 0; i < n; i += 2)result ^= (i == 0) ? (pInt[0] - 1) : (pInt[i] - pInt[i - 1] - 1);elsefor (int i = 1; i < n; i += 2)result ^= (pInt[i] - pInt[i - 1] - 1);if (result) return "Georgia will win";else return "Bob will win";
}int main() {cin >> t;for (int i = 0; i < t; ++i) {cin >> n;memset(p, 0, sizeof(p));for (int j = 0; j < n; ++j)cin >> p[j];ans[i] = deal(p,n);}for (int i = 0; i < t; ++i)cout << ans[i] << endl;return 0;
}

Georgia and Bob POJ - 1704相关推荐

  1. Georgia and Bob POJ - 1704 阶梯Nim

    $ \color{#0066ff}{ 题目描述 }$ Georgia and Bob decide to play a self-invented game. They draw a row of g ...

  2. Georgia and Bob(Poj 1704)Nim 博弈

    Georgia and Bob 思路 每个棋子只能向左移动并且不能越过其左边的棋子,这就有点像是经典的nim博弈了, 但是在这里后一个石子会受到其前一个石子位置的影响,这里就需要转化一下了. 我们假设 ...

  3. POJ - 1704 Georgia and Bob

    Georgia and Bob 题意: 一个水平网格上有N个棋子 Georgia和Bob每到自己回合时可以向左移动网格上任意一个棋子任意步数 棋子与棋子之间不能重叠和相互跨越 当到对手回合时,其无法再 ...

  4. 博弈最高位POJ 1704(Georgia and Bob-Nim博弈)

    新手发帖,很多方面都是刚入门,有错误的地方请大家见谅,欢迎批评指正 Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Su ...

  5. 博弈论(阶梯博弈)POJ 1704

    对阶梯博弈的阐述:博弈在一列阶梯上进行,每个阶梯上放着自然数个点.两个人进行阶梯博弈,每一步则是将一个集体上的若干个点( >=1 )移到前面去,最后没有点可以移动的人输 证明方式:如这就是一个阶 ...

  6. POJ 1704 Georgia and Bob (Nim游戏变形)

    题目:http://poj.org/problem?id=1704 思路:Nim游戏策略,做如下转换,如果N是偶数,则两两配对,将两个数之间的格子数(距离)看做成这一堆石头的数量. 如果N是奇数,则将 ...

  7. poj 1704 HDU-4315 阶梯博弈

    本博文只提供思路,不提供代码,需要代码的同学请访问他人博文 n个石子,每个石子占有一个位置,不超过前面石子的前提下可以向前挪任意格,最先把石子全挪出去的获胜 阶梯博弈详解https://blog.cs ...

  8. (转载)--SG函数和SG定理【详解】

    在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜点和必败点的概念: P点:必败点,换而言之,就是谁处于此位置,则在双方操作正确的情况下必败. N点:必胜点,处于此情况下,双方操作均正 ...

  9. 组合博弈游戏 - SG函数和SG定理

    转载来自:http://blog.csdn.net/luomingjun12315/article/details/45555495 在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜 ...

最新文章

  1. 【Dijkstra】最短路径
  2. python应用于财务-用6行python代码做一个财务机器人
  3. python 简单的server请求
  4. HDU 5676 ztr loves lucky numbers
  5. wxWidgets:将 PNG 图像文件包含到可执行文件中
  6. bash shell数组模拟队列queue和shell数组使用技巧
  7. KUKA通信 CREAD问题
  8. Windows11 发布更新 Insider Preview Build 22000.100
  9. mysql管理节点_MySql节点管理安装步骤需要在SerA和SerB上各做一次
  10. Facebook 约十亿美元收购脑机技术公司,助攻AR研发;苹果宣布新款 Mac Pro 在美国生产;谷歌称已实现量子霸权…...
  11. 报表如何同步用户数据集 1
  12. UIKit框架-基础控件Swift版本: 7.UISwitch方法/属性详解
  13. IOS环境下APP应用完整性测试流程
  14. Spring boot Redis 乱码
  15. redis-----简单介绍---基本的配置---持久化----学习笔记
  16. java 两张图片合并_java实现把两张图片合并(Graphics2D)
  17. PDF编辑方法,怎么给PDF添加页码
  18. 基于jws发布webservice服务
  19. 如何利用免费工具轻松实现个人号裂变?
  20. 导出word单元格间隔空白问题

热门文章

  1. winfrom保存图片,将文件夹中图片放入listview,与撤回操作
  2. ASP.NET 5 入门(1) - 建立和开发ASP.NET 5 项目
  3. webview改变网页宽度
  4. python定义构造函数、包括颜色价格品牌_《Python编程与算法基础教程》(第二版),蒋洪宇,青松,第9章:课后练习,程序设计,版江红余,第九章,习题,答案...
  5. Java黑皮书课后题第5章:5.11(找出能被5或6整除的数,但不能同时整除)编写程序,显示从100到1000之间能被5或6整除但不能同时整除的数,每行显示10个。数字之间用一个空格字符隔开
  6. 1.编写程序,打印基本ASCII码表(可印刷32到126)。
  7. idea 启动php项目路径,关于idea中Java Web项目的访问路径问题
  8. Internet History, Technology, and Security(week5)——Technology: Internets and Packets
  9. luogu P2512 [HAOI2008]糖果传递
  10. 第一章 初识Linux shell