题目链接:uva 1378 - A Funny Stone Game 题目大意:两个人玩游戏,对于一个序列,轮流操作.每次选中序列中的i,j,k三个位置要求i<j≤k,然后arr[i]减1,对应的arr[j]和arr[k]加1,不能操作的人输,问先手是否必胜.必胜的话给出字典序最下的必胜方案.负责输出-1. 解题思路:首先预处理出各个位置上的SG值,然后对于给定序列,枚举位置转移状态后推断是否为必败态就可以. #include <cstdio> #include <cstring&…
1378 - A Funny Stone Game Time limit: 3.000 seconds The funny stone game is coming. There are n piles of stones, numbered with 0, 1, 2,..., n - 1. Two persons pick stones in turn. In every turn, each person selects three piles of stones numbered i, j…
F - Again Stone Game Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Description Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the…
UVA 11534 - Say Goodbye to Tic-Tac-Toe 题目链接 题意:给定一个序列,轮流放XO,要求不能有连续的XX或OO.最后一个放的人赢.问谁赢 思路:sg函数.每一段...看成一个子游戏,利用记忆化求sg值,记忆化的状态要记录下左边和右边是X还是O就可以 代码: #include <stdio.h> #include <string.h> const int N = 105; int t, sg[3][3][N]; char str[N]; int g…
A Chess Game Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 3917 Accepted: 1596 Description Let's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1729 看了题目感觉像Nim,但是有范围限制,有点不知道SG函数该怎么写 看了题解,最后才明白该怎么去理解 . 首先进行对s和c进行分类, 1.c = 0 的时候,无论怎样都填不满,直接跳过: 2.c = s 的时候,先手必败,即是P态: 3.c < s 的时候,可以分为两种情况: 1)c^2 + c < s 的时候,递归 2)c^2 + c > s 的时候,先手必胜,即N态 int mex(…
这道题确实没有一个很好的解决办法 唯一的正解可能就是打表找规律 或者 直接猜结论了吧. 尽管如此 在此也给最终结论一个完整的证明. 对于70分 容易发现状态数量不大 可以进行暴力dp求SG函数. 原本打算打表 实测状态数量只有1e5左右. const int maxn=800; int T,ans; int vis[100010]; int f[141][58][30][15];//表示当前状态为这个东西时的SG函数. int main() { freopen("a.in","…
Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the game and they alternate moves. In each move, a player has to select any pile and should remove at least one and no more t…
ZOJ 3529 - A Game Between Alice and Bob Time Limit:5000MS Memory Limit:262144KB 64bit IO Format:%lld & %llu Description Alice and Bob play the following game. A series of numbers is written on the blackboard. Alice and Bob take turns choosing…
C - Playing With Stones Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Practice UVALive 5059 Description You and your friend are playing a game in which you and your friend take turns removing stones from piles.…
Stone Game II comes. It needs two players to play this game. There are some piles of stones on the desk at the beginning. Two players move the stones in turn. At each step of the game the player should do the following operations. First, choose a p…
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9296 Accepted Submission(s): 3893 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;…