http://acm.hdu.edu.cn/showproblem.php?pid=4315

题意:有n个人要往坐标为0的地方移动,他们分别有一个位置a[i],其中最靠近0的第k个人是king,移动的时候在后面的人不能越过前面的人,先把king送到0的人胜。

思路:阶梯博弈。把n个人两两配对,形成一个组,即a[i]和a[i+1]是一个组,a[i+2]和a[i+3]是一个组,把a[i]和a[i+1]的距离当成阶梯博弈中的奇数阶的值,a[i+1]和a[i+2]的距离当成偶数阶(不用考虑)。首先k=1时候先手赢。偶数情况下,两两相邻是必败态,因为如果先手移动前面的,后手一定可以使得局面还是两两相邻,然后先手移动king前面的人的时候,后手只要把king移动到终点。如果n是奇数的话,把a[1]走到终点就是偶数的情况。所以如果k是第二个人并且n是奇数的话,第一个人只能移动到1的位置,否则k就能直接移动到0了,因此a[1]要-1。

 #include <cstdio>
#include <cstring>
using namespace std;
#define N 1010
int id[N];
int c[N]; int main() {
int n, k;
while(scanf("%d%d", &n, &k) != EOF) {
for(int i = ; i <= n; i++) scanf("%d", id+i);
if(k == ) {
puts("Alice");
} else {
int ans = ;
if(n & && k == ) id[]--;
for(int i = + (n & ); i <= n; i += )
ans ^= (id[i] - id[i-] - );
if(n & ) ans ^= id[];
if(ans) puts("Alice");
else puts("Bob");
}
}
return ;
}

HDU 4315:Climbing the Hill(阶梯博弈)的更多相关文章

  1. HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)

    Climbing the Hill Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Su ...

  2. HDU 4315 Climbing the Hill [阶梯Nim]

    传送门 题意: 和上题基本一样:山顶可以有多人,谁先把king放到山顶谁就胜 并不太明白 #include <iostream> #include <cstdio> #incl ...

  3. HDU 4315 Climbing the Hill(阶梯博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=4315 题意:由上至下有多个格子,最顶端的是山顶,有多个球,其中有一个球是king,每次可以将球向上移动任意个格子 ...

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

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

  5. hdu 4315 Climbing the Hill(阶梯博弈转nim博弈)

    Climbing the Hill Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. hdu 4315 Climbing the Hill 博弈论

    题意:有n个人爬山,山顶坐标为0,其他人按升序给出,不同的坐标只能容纳一个人(山顶不限),Alice和Bob轮流选择一个人让他移动任意步,但不能越过前面的人,且不能和前面一个人在相同的位置.现在有一个 ...

  7. 【hdu 4315】Climbing the Hill

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

  8. HDU 4315 阶梯博弈变形

    n个棋子,其中第k个是红色的,每个棋子只能往上爬,而且不能越过.重叠其他棋子,谁将红色棋子移到顶部谁赢. 由于只能往上爬,所以很像阶梯博弈.这题有2个限制,棋子不能重叠,有红棋存在 首先不考虑红色棋, ...

  9. HDU 3389 阶梯博弈变形

    n堆石子,每次选取两堆a!=b,(a+b)%2=1 && a!=b && 3|a+b,不能操作者输 选石子堆为奇数的等价于选取步数为奇数的,观察发现 1 3 4 是无法 ...

随机推荐

  1. 修改了系统自带头文件后,Xcode会报错

    1.Xcode自带头文件的路径 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Develo ...

  2. lua对模块接口扩展的一种方法

    module lua中模块的实现,对于使用者来说就是一个库,引用此库后,可以调用库中实现的任意函数. 使用库,可以将一类功能相关的接口做封装,并提供开放接口. 参考: http://blog.codi ...

  3. git客户端

    https://git-for-windows.github.io/ http://blog.csdn.net/shulianghan/article/details/18812279 自己的gith ...

  4. Git_Commands

  5. Website English Comments

    幻灯新闻下方的广告 Slide news at the bottom of the advertisement 人才招聘 recruitment 左/右侧推荐区 The left/right side ...

  6. Leetcode: Kth Smallest Element in a Sorted Matrix

    Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth ...

  7. FOJ 2013 11 月赛

    这套题目还是比较吊的,由于我的沙茶,还是很多没有做出来- -! C:逆序数 D:呵呵 A:妈蛋,自己精度没弄好,想到之前GCC的要加eps,就WA了几次后交Visual C++过了!C(n,m)p^m ...

  8. 01分数规划zoj2676(最优比例,最小割集+二分)

    ZOJ Problem Set - 2676         Network Wars Time Limit: 5 Seconds      Memory Limit: 32768 KB      S ...

  9. codevs 1201 最小数和最大数

    http://codevs.cn/problem/1201/ 1201 最小数和最大数  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 青铜 Bronze 题解       题 ...

  10. cocos游戏开发之海岛冒险1

    1.首先在cocosStudio软件中新建项目:项目名称IslandAdventure:项目语言:C++ 2.在项目路径F:\cocos\MyProject\IslandAdventure如下: 3. ...