codeforces 493 D Vasya and Chess【 博弈 】

题意:给出n*n的棋盘,白方在(1,1),黑方在(1,n)处,每一步可以上下左右对角线走,哪个先抓到另一个,则它获胜

可以画一下,发现n是奇数的时候,白方先走,无论它怎么走,黑方和它走对称的,黑方都一定能赢

n是偶数的时候,将白方走到(1,2)就变成奇数的情况,白方必胜

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include <cmath>
 5 #include<stack>
 6 #include<vector>
 7 #include<map>
 8 #include<set>
 9 #include<queue>
10 #include<algorithm>
11 using namespace std;
12
13 typedef long long LL;
14 const int INF = (1<<30)-1;
15 const int mod=1000000007;
16 const int maxn=1000005;
17
18 int main(){
19     int n;
20     scanf("%d",&n);
21     if(n&1) puts("black");
22     else printf("white\n1 2\n");
23     return 0;
24 }

时间: 2024-07-31 21:38:51

codeforces 493 D Vasya and Chess【 博弈 】的相关文章

Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈

D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess. The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is

codeforces 493D Vasya and Chess(博弈?)

传送门:点击打开链接 题目大意: 给一个N*N的棋盘.然后一开始 白队的Queen在(1,1),黑队的Queen在(1,n). 其余的点都是绿棋子. Queen可以走横竖和斜线.(就是国际象棋里面Queen的走法,但是必须要吃子). 问白方先走.谁能嬴(没得走或者被吃了就死了) 解题思路: 博弈题..习惯性乱猜 就过了.写的比A还快. 猜法如下:每个人各走一步,可以使得总奇偶性不变.然后只要知道一开始的距离的奇偶性.就知道谁先死了.(勿喷) #include <cstdio> #include

codeforces 493 C Vasya and Basketball

题意:给出三分线的值d,分别有两支队伍,如果小于等于d,得2分,如果大于d,得三分,问使得a-b最大时的a,b 一看到题目,就想当然的去二分了----啥都没分出来---55555555 后来才知道不能二分,因为随着d的增大,两个队的得分都会逐渐减少,但是两个队伍的得分的差值的单调性却不知道 是这一篇这样讲的 http://www.cnblogs.com/huangxf/p/4142760.html 然后就依次枚举d的值,维护一个最大值 1 #include<iostream> 2 #inclu

CodeForces 493D Vasya and Chess 简单博弈

Vasya and Chess Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u CodeForces 493D Description Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess. The quee

codeforces 493 ABCD

A. Vasya and Football A. Vasya and Football time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Vasya has started watching football games. He has learned that for some fouls the players receiv

CodeForces 259A Little Elephant and Chess

Little Elephant and Chess Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 259A Description The Little Elephant loves chess very much. One day the Little Elephant and his friend decided t

Codeforces 538E Demiurges Play Again(博弈DP)

http://codeforces.com/problemset/problem/538/E 题目大意: 给出一棵树,叶子节点上都有一个值,从1-m.有两个人交替从根选择道路,先手希望到达的叶子节点尽量大,后手希望到达的叶子节点尽量小,叶子节点的放置方案任意.两个人都足够聪明,能够得到的最大值和最小值分别是多少. 思路: 先考虑最大的情况 考虑dp[i]代表i这个节点能达到的最大的数字在这个子树中排第几. 如果当前是先手操作,那么他肯定会往最大的那个子树的方向走,即dp[u]=min(dp[v]

Codeforces 559C Gerald and Giant Chess

http://codeforces.com/problemset/problem/559/C 题目大意:给出一个棋盘为h*w,现在要从(1,1)到(h,w),只能向右或向下走,其中有n个黑点不能走,问有多少种方案(模10^9+7)可以从左上角走到右下角(1,1和h,w永远是可以走的) 思路:用dp,首先把终点也算入黑点,然后dp这样: f[i]=从起点到这个点的所有路径数 f[i]-f[j]*从j点到i点的所有路径数 为什么这样?因为我们先算出总的路径数,再去掉不合法的路径数,也就是:从经过第一

codeforces 1041 E.Vasya and Good Sequences(暴力?)

E. Vasya and Good Sequences time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has a sequence $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. Vasya may pefrom the fol