uva10561 - Treblecross】的更多相关文章

Treblecross is a two player gamewhere the goal is to get three X in a row on a one-dimensional board. At the startof the game all cells in the board is empty. In each turn a player puts a X in an empty cell, and if that results in there beingthree X…
Treblecross is a two player game where the goal is to get three `X' in a row on a one-dimensional board.At the start of the game all cells in the board is empty. In each turn a player puts a `X' in an emptycell, and if that results in there being thr…
题目链接:https://vjudge.net/problem/UVA-10561 题意: 两个人玩游戏,轮流操作:每次往里面添加一个X,第一个得到XXX的获胜. 题解: 详情请看<训练指南>P139,以及代码注释. 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include…
题意:有n个格子排成一行,其中一些格子里面有字符X.两个游戏者轮流操作,每次可以选一个空格,在里面放上字符X. 如果此时有3个连续的X出现,则该游戏者赢得比赛.初始条件下不会有3个X连续出现. 判断先手胜负情况,若必胜则升序输出先手第一步的所有可选必胜策略 n<=200 思路:如果有XX或者X.X出现则一定先手胜 一个结论:X的旁边和旁边的旁边不能放X 于是整个游戏被不能放X的区域分成了若干个独立的片段,每次都可以选择一个片段进行游戏,就是若干个游戏的和 由于每个棋盘片段都是连续的,想到用一个正…
Treblecross is a two player game where the goal is to get three X in a row on a one-dimensional board. At the start of the game all cells in the board are empty. In each turn a player puts an X in an empty cell, and if the move results three X next t…
UVA 10561 - Treblecross 题目链接 题意:给定一个串,上面有'X'和'.',能够在'.'的位置放X.谁先放出3个'X'就赢了,求先手必胜的策略 思路:SG函数,每一个串要是上面有一个X,周围的4个位置就是禁区了(放下去必败).所以能够以X分为几个子游戏去求SG函数的异或和进行推断.至于求策略.就是枚举每一个位置就能够了 代码: #include <stdio.h> #include <string.h> #include <algorithm> u…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1502 博弈 SG  不可以使出现 XX 或者 X.X的情况,这样下一个人就赢了 枚举每个.将其变成X 看是否可以让对手输 1,已经出现了  XXX  对手已输 2,如果正好出现了  XX 或者 X.X  对手赢 3,如果一个地方的.变成X   不会出现XX或者X.X  把这些地方分成一个个的…
如果已经有三个相邻的X,则先手已经输了. 如果有两个相邻的X或者两个X相隔一个.,那么先手一定胜. 除去上面两种情况,每个X周围两个格子不能再放X了,因为放完之后,对手下一轮再放一个就输了. 最后当“禁区”布满整行,不能再放X了,那个人就输了. 每放一个X,禁区会把它所在的线段“分割”开来,这若干个片段就可以看做若干个游戏的和. 设g(x)表示x个连续格子对应的SG函数值,递推来求g(x): g(x) = mex{ g(x-3), g(x-4), g(x-5), g(x-6) xor g(1),…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=32209 [思路] 博弈论. 根据X分布划分禁区,每个可以放置的块为单独一个游戏.按长度定义状态,构造sg函数.依次试验每一种放法. [代码] #include<cstdio> #include<vector> #include<cstring> #include<algorithm> using namespace std;…
Description Given the value of N, you will have to find the value of G. The meaning of G is given in the following code G=0; for(i=1;i&ltN;i++) for(j=i+1;j<=N;j++) G+=gcd(i,j); /*Here gcd() is a function that finds the greatest common divisor of th…