Georgia and Bob
给出一个严格递增的正整数数列\(\{a_i\}\),每一次操作可以对于其中任意一个数减去一个正整数,但仍然要保证数列的严格递增性,现在两名玩家轮流操作,不能操作的玩家判负,询问先手是否能够必胜。
解
注意到除去严格递增性后,就是Nim游戏了,所以问题主体依赖于Nim定理,于是要设法转化为Nim游戏,这里采取捆绑法,也就是阶梯博弈,从最后一个数开始,每两个作为一对,第一个如果无数捆绑,则与0捆绑。
此时,对手如果对一对数中的前一个进行操作,你必然可以对这对数的后一个数进行同样的操作,即减掉相同的数,因此相对位移不会发生改变,而对手或者你对一对数中的后一个数进行操作,即改变了两个数的相对位移,所以实际上发生改变的,也就是影响最终局面的也就是相对位移。
于是我们可以排好序,捆绑好数,算出相对位移,套用Nim定理即可。
参考代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
#define il inline
#define ri register
using namespace std;
int p[1001];
il void read(int&);
int main(){
int lsy,n,i,ans;read(lsy);
while(lsy--){read(n);
for(i=1;i<=n;++i)read(p[i]);
sort(p+1,p+n+1),ans&=0;
for(i=n;i>0;i-=2)ans^=(p[i]-p[i-1]-1);
puts(ans?"Georgia will win":"Bob will win");
}
return 0;
}
il void read(int &x){
x&=0;ri char c;while(c=getchar(),c<'0'||c>'9');
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
Georgia and Bob的更多相关文章
- POJ1704 Georgia and Bob
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9771 Accepted: 3220 Description Georg ...
- POJ1704 Georgia and Bob (阶梯博弈)
Georgia and Bob Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u Subm ...
- [原博客] POJ 1704 Georgia and Bob
题目链接题意:如图,Georgia和Bob在玩游戏.一个无限长的棋盘上有N个旗子,第i个棋子的位置可以用Pi表示.现在Georgia先走.每个人每一次可以把一枚棋子向左移动任意个格子,但是不能超越其他 ...
- poj 1704 Georgia and Bob(阶梯博弈)
Georgia and Bob Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8656 Accepted: 2751 D ...
- 【POJ】1704 Georgia and Bob(Staircase Nim)
Description Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, ...
- poj 1704 Georgia and Bob(阶梯博弈)
Georgia and Bob Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9363 Accepted: 3055 D ...
- POJ 1704 Georgia and Bob(阶梯Nim博弈)
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11357 Accepted: 3749 Description Geor ...
- 【POJ1704】Georgia and Bob(博弈论)
[POJ1704]Georgia and Bob(博弈论) 题面 POJ Vjudge 题解 这种一列格子中移动棋子的问题一般可以看做成一个阶梯博弈. 将一个棋子向左移动时,它和前面棋子的距离变小,和 ...
- [POJ1704]Georgia and Bob 博弈论
从这开始我们来进入做题环节!作为一个较为抽象的知识点,博弈论一定要结合题目才更显魅力.今天,我主要介绍一些经典的题目,重点是去理解模型的转化,sg函数的推理和证明.话不多说,现在开始! Georgia ...
- Georgia and Bob POJ - 1704 阶梯Nim
$ \color{#0066ff}{ 题目描述 }$ Georgia and Bob decide to play a self-invented game. They draw a row of g ...
随机推荐
- fabric.js 限制缩放的最大最小比例
var rect = new fabrics.Rect({ v: true, top: 216, left: 384, width: 160, height: 90, fill: 'transpare ...
- Web 开发规范 — WSGI
目录 目录 WSGI 简介 为什么需要 WSGI 这个规范 WSGI 如何工作 WSGI的角色 Server 如何调用 Application application 的两个参数 applicatio ...
- Memory barrier,
A memory barrier, also known as a membar, memory fence or fence instruction, 是一种屏障指令,它使中央处理单元(CPU)或编 ...
- VBA提取HTML文件信息
Sub test() Dim html As Object, D As Object, W As Object, arr() Set html = CreateObject("m ...
- vue-router如何参数传递
1.我们用<router-link>标签中的to属性进行传参,需要您注意的是这里的to要进行一个绑定,写成:to 先来看一下这种传参方法的基本语法: <router-link :to ...
- 学习 Apache FileMatchs 规则
# 凡是匹配到 zip,gz,rar,box,log结尾的文件,进行下面的规则进行匹配 <filesmatch ".(zip|gz|rar|box|log)"> Ord ...
- openwrt_ipsec_racoon.init 分析
racoon.init 脚本分析,基于openwrt 官方的脚本分析 #!/bin/sh /etc/rc.common # 包含了文件, 这个会继续分析 # # Copyright (C) Vital ...
- Python自学:第五章 使用函数range( )
# -*- coding: GBK -*- for value in range(1,5): print(value) 输出为: 1 2 3 4
- csps模拟87888990部分题解
题面:https://www.cnblogs.com/Juve/articles/11752338.html https://www.cnblogs.com/Juve/articles/1175241 ...
- 线段树离散化+区间更新——cf1179C好题
绝对是很好的题 把问题转化成当第i个询问的答案是数值x时是否可行 要判断值x是否可行,只要再将问题转化成a数组里>=x的值数量是否严格大于b数组里的>=x的值 那么线段树叶子结点维护对于值 ...