Georgia and Bob
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 9363   Accepted: 3055

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: 

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?

Input

The first line of the input contains a single integer T (1 <= T <= 20), the number of test cases. Then T cases follow. Each test case contains two lines. The first line consists of one integer N (1 <= N <= 1000), indicating the number of chessmen. The second line contains N different integers P1, P2 ... Pn (1 <= Pi <= 10000), which are the initial positions of the n chessmen.

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
/*
poj 1704 Georgia and Bob(阶梯博弈) 一行棋盘,每次可以将一个棋子往左边移动,但是不能跨越棋子
每次移动时,和左边的间距变小了,与右边的间距变大
可以等效于阶梯博弈,每次将一个台阶上的棋子往下移动。 本台阶石子变少,下一个台阶的石子边多
转化一下就好了 hhh-2016-08-02 21:26:32
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <functional>
typedef long long ll;
#define lson (i<<1)
#define rson ((i<<1)|1)
using namespace std;
const int maxn = 10000+10; int sg[maxn];
int s[maxn];
int n; void SG(int now)
{
if(sg[now] != -1)
return ;
int vis[maxn];
memset(vis,0,sizeof(vis));
for(int i = 0; i < n; i++)
{
int t = now-s[i];
if(t < 0)
continue;
SG(t);
vis[sg[t]] = 1;
} for(int i = 0;; i++)
{
if(!vis[i])
{
sg[now] = i;
break;
}
}
} int main()
{
int x,m;
int a[maxn];
// freopen("in.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n) ;
for(int i = 0; i < n; i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
int ans;
if(n % 2 == 0)
ans = 0;
else
ans = a[0]-1;
for(int i = n-1; i > 0; i -= 2)
{
ans ^= (a[i] - a[i-1] -1);
}
if(ans)
printf("Georgia will win\n");
else
printf("Bob will win\n");
}
return 0;
}

  

poj 1704 Georgia and Bob(阶梯博弈)的更多相关文章

  1. hdu 4315 Climbing the Hill && poj 1704 Georgia and Bob阶梯博弈--尼姆博弈

    参考博客 先讲一下Georgia and Bob: 题意: 给你一排球的位置(全部在x轴上操作),你要把他们都移动到0位置,每次至少走一步且不能超过他前面(下标小)的那个球,谁不能操作谁就输了 题解: ...

  2. POJ 1704 Georgia and Bob(阶梯Nim博弈)

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11357   Accepted: 3749 Description Geor ...

  3. POJ 1704 Georgia and Bob【博弈】

    题目链接: http://poj.org/problem?id=1704 题意: 给定棋子及其在格子上的坐标,两个人轮流选择一个棋子向左移动,每次至少移动一格,但是不可以碰到其他棋子.无路可走的时候视 ...

  4. POJ 1704 Georgia and Bob [阶梯Nim]

    题意: 每次可以向左移动一个棋子任意步,不能跨过棋子 很巧妙的转化,把棋子间的空隙看成石子堆 然后裸阶梯Nim #include <iostream> #include <cstdi ...

  5. POJ 1704 Georgia and Bob(阶梯博弈+证明)

    POJ 1704 题目链接 关于阶梯博弈有如下定理: 将所有奇数阶梯看作n堆石头,做Nim,将石头从奇数堆移动到偶数堆看作取走石头,同样地,异或值不为0(利己态)时,先手必胜. 定理证明看此博:htt ...

  6. poj 1704 Georgia and Bob(阶梯博弈)

    Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8656   Accepted: 2751 D ...

  7. POJ 1704 Georgia and Bob(阶梯博弈)题解

    题意:有一个一维棋盘,有格子标号1,2,3,......有n个棋子放在一些格子上,两人博弈,只能将棋子向左移,不能和其他棋子重叠,也不能跨越其他棋子,不能超越边界,不能走的人输 思路:可以用阶梯博弈来 ...

  8. POJ1704 Georgia and Bob (阶梯博弈)

    Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u Subm ...

  9. POJ.1704.Georgia and Bob(博弈论 Nim)

    题目链接 \(Description\) 一个1~INF的坐标轴上有n个棋子,给定坐标Pi.棋子只能向左走,不能跨越棋子,且不能越界(<1).两人每次可以将任意一个可移动的棋子向左移动一个单位. ...

随机推荐

  1. Alpha冲刺Day1

    项目Alpha冲刺Day1 一.站立式会议 照片: 今日安排: 今天是项目开始的第一天,我们小组一起开会讨论了一下具体每天代码进度的落实情况,做了一下大体的规划.另外准备搭建一下环境和项目部署. 二. ...

  2. Python 实现队列

    操作 Queue() 创建一个空的队列 enqueue(item) 往队列中添加一个item元素 dequeue() 从队列头部删除一个元素 is_empty() 判断一个队列是否为空 size() ...

  3. day-2 如何搭建一个github代码库

    最近在听尤瓦尔·赫拉利代写的两本书<人类简史>和<未来简史>两本书评,一部描述人类从哪里来,一部描述人类将往哪里去,书中阐述以前我们经历的饥饿.疾病和战争已经渐渐逝去,未来我们 ...

  4. MVC Form 表单 提交 集合 及 复杂对象

    public class Customer { public string FName{get;set;} public Address address{get;set;} } public clas ...

  5. MySQL Group Relication 部署环境入门篇

      一:环境介绍   cenos 6.7 版本 数据库的版本5.7.19 二:部署规划单机多实例的部署   端口号 数据目录  group_repplicatoon 通信接口   3307 /data ...

  6. JWT

    Web安全通讯之Token与JWT http://blog.csdn.net/wangcantian/article/details/74199762 javaweb多说本地身份说明(JWT)之小白技 ...

  7. Docker学习笔记 - Docker的数据卷

    一.什么是数据卷? 数据卷是一个可供一个或多个容器使用的特殊目录,它绕过 UFS,可以提供很多有用的特性: 数据卷可以在容器之间共享和重用 对数据卷的修改会立马生效 对数据卷的更新,不会影响镜像 数据 ...

  8. HTTP协议扫盲(三)HTTP协议的请求头列表和分类描述

    一.请求报头和响应报头列表 1.Requests 头列表 Header 解释 示例 Accept 指定客户端能够接收的内容类型 Accept: text/plain, text/html Accept ...

  9. C#微信公众号——自定义菜单

    自定义菜单最多包括3个一级菜单,每个一级菜单最多包含5个二级菜单.一级菜单最多4个汉字,二级菜单最多7个汉字,多出来的部分将会以“...”代替.自定义菜单的介绍,可以看官方开发文档http://mp. ...

  10. 数据结构 Python实现

    参考博客:浅谈算法和数据结构: 一 栈和队列   Python数据结构--栈.队列的实现(一)    Python数据结构--栈.队列的实现(二)    Python数据结构--链表的实现 数据结构 ...