题意

题目链接

很难概括。。

Sol

(因为比赛还没结束,所以下面讲的可能是“非官方”“正解”)

maya这题我前前后后 断断续续的做了一个星期才A掉。CC一场challenge出两道打表题可有点过分了啊。。

首先考虑暴力怎么打,我们把给出的初始行列的01取反,这样$0$的时候对应的是必胜态,$1$对应的是必败态。

然后按博弈论的定义推,$(i, j)$若是必胜态,那么至少有$(i - 1, j)$是必败态 或者 $(i, j - 1)$是必败态。

然后暴力枚举一遍就行了,复杂度$O(NM)$

接下来的操作就比较神仙了,,打表 或 直接观察式子可得,若第$(i, j)$个点是必败点,那么它所在的对角线往后的点,都是必败点!

这样我们就把状态降到了$2 * M$

那最开始的必败点怎么求呢?

直觉告诉我们 稍加证明不难得到,这种点一定是出现在前两行 或者前两列。

然后就做完了。

暴力推前两行 前两列即可。

保险起见我推了三行三列。

#include<cstdio>
#include<cstring>
#include<vector>
#define LL long long
using namespace std;
const int MAXN = 1e5 + ;
inline LL read() {
char c = getchar(); LL x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int T;
int a[][MAXN], b[MAXN][], N, M, f[MAXN], g[MAXN];
char A[MAXN], B[MAXN];
int main() {
//- freopen("a.out", "w", stdout);
int T = read();
while(T--) {
scanf("%s", A + );
scanf("%s", B + );
M = strlen(A + );
N = strlen(B + );
for(int i = ; i <= M; i++) a[][i] = (A[i] == '' ? : );
for(int i = ; i <= ; i++) a[i][] = (B[i] == '' ? : ); for(int i = ; i <= ; i++) b[][i] = (A[i] == '' ? : );
for(int i = ; i <= N; i++) b[i][] = (B[i] == '' ? : ); memset(f, 0x7f, sizeof(f));
memset(g, 0x7f, sizeof(g)); for(int i = ; i <= ; i++) {
for(int j = ; j <= M; j++) {
if(a[i - ][j] == || a[i][j - ] == ) a[i][j] = ;//能到达必败节点的
else a[i][j] = ;
if(a[i][j] == ) f[j - i + ] = min(f[j - i + ], i);
}
} for(int i = ; i <= N; i++) {
for(int j = ; j <= ; j++) {
if(b[i - ][j] == || b[i][j - ] == ) b[i][j] = ;
else b[i][j] = ;
if(b[i][j] == ) g[i - j + ] = min(g[i - j + ], j);
}
}
vector<int> ans;
int Q = read();
while(Q--) {
int x = read(), y = read();
int dy = y - x + ,
dx = x - y + ;
if(dy >= ) {
if(x >= f[dy]) ans.push_back();
else ans.push_back();
} else {
if(y >= g[dx]) ans.push_back();
else ans.push_back();
}
}
for(int i = ; i < ans.size(); i++) printf("%d", ans[i]);
puts("");
} return ;
}
/*
2
101
01
6
1 1
1 2
1 3
2 1
2 2
2 3
101
01
6
1 1
1 2
1 3
2 1
2 2
2 3
*/

codechef Table Game(博弈)的更多相关文章

  1. codechef Graph on a Table

    codechef Graph on a Table https://www.codechef.com/problems/TBGRAPH 题意 : 一个\(n\times m\)的网格图.\(q\) 个 ...

  2. UVa 1609 (博弈) Foul Play

    姑且把它归类为一道博弈吧,毕竟这也是在找必胜方案. 十分有意思的一道题目,设计一种方案让你支持的1队获胜. 题目给出了两个很重要的条件: 1队能打败至少一半的队伍 对于1队不能打败的黑队,一定存在一个 ...

  3. UVA 10404 Bachet's Game(dp + 博弈?)

    Problem B: Bachet's Game Bachet's game is probably known to all but probably not by this name. Initi ...

  4. Codechef September Challenge 2018 游记

    Codechef September Challenge 2018 游记 Magician versus Chef 题目大意: 有一排\(n(n\le10^5)\)个格子,一开始硬币在第\(x\)个格 ...

  5. UVA12293 Box Game —— SG博弈

    题目链接:https://vjudge.net/problem/UVA-12293 题意: 两人玩游戏,有两个盒子,开始时第一个盒子装了n个球, 第二个盒子装了一个球.每次操作都将刷量少的盒子的球倒掉 ...

  6. UVA1482 Playing With Stones —— SG博弈

    题目链接:https://vjudge.net/problem/UVA-1482 题意: 有n堆石子, 每堆石子有ai(ai<=1e18).两个人轮流取石子,要求每次只能从一堆石子中抽取不多于一 ...

  7. CodeChef A String Game(SG)

    A String Game   Problem code: ASTRGAME   Submit All Submissions   All submissions for this problem a ...

  8. Codeforces 388C Fox and Card Game (贪心博弈)

    Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her fr ...

  9. Codeforces Gym-100985C: MaratonIME plays Nim(交互题&博弈)

    C. MaratonIME plays Nim time limit per test : 2.0 smemory limit per test : 64 MBinputstandard inputo ...

随机推荐

  1. XAMPP中Apache因为端口原因不能启动的解决方法

    在开启XAMPP的Apache时报出如下错误信息: 9:08:14 PM [Apache] Error: Apache shutdown unexpectedly.9:08:14 PM [Apache ...

  2. SSH2整合需要jar包解释

    hibernate3.jar, Hibernate的库,必须使用的jar包 antlr-2.7.6.jar, 语法分析生成器 语言转换工具,hibernate利用它实现HQL到SQL的转换 cglib ...

  3. 支持FreeMarker需要哪些JAR包?

    FreeMarker所需的全部jar包,Jar包:struts2-core-2.0.11.2.jar,xwork-2.0.5.jar,ognl-2.6.11.jar,freemarker-2.3.8. ...

  4. PyCharm Django项目开发的调试方法

    下面介绍两种PyCharm Django项目开发的调试方法: 方法一: 1. 使用PyCharm 自带的django项目Debug工具, 当然前提条件是django项目环境已经搭建好了. 2. 在代码 ...

  5. mac git 命令自动补全

    步骤如下: 1.下载Git-completion.bash 或者直接使用SourceTree去clone到本地. 下载地址:https://github.com/markgandolfo/git-ba ...

  6. 最简单的PS渐变导入方法 photoshop渐变插件素材导入教程

    photoshop渐变插件素材可以让用户更好更直接,更快速地设计出自己想要的效果作品.网上有多种多样的ps渐变,那么Mac版Ps渐变怎么导入呢?这里我来和大家分享一下photoshop渐变插件素材导入 ...

  7. HDU 2897 邂逅明下 ( bash 博弈变形

    HDU 2897 邂逅明下 ( bash 博弈变形 题目大意 有三个数字n,p,q,表示一堆硬币一共有n枚,从这个硬币堆里取硬币,一次最少取p枚,最多q枚,如果剩下少于p枚就要一次取完.两人轮流取,直 ...

  8. 使用OrgChart插件生成家谱组织结构图

    1.orgchart插件: github地址:https://github.com/dabeng/OrgChart 2.前端代码: //1.加载树形数据:ajax请求获取json格式的数据(flag参 ...

  9. 03 Oracle分区表

    Oracle分区表   先说句题外话…   欢迎成都天府软件园的小伙伴来面基交流经验~ 一:什么是分区(Partition)? 分区是将一个表或索引物理地分解为多个更小.更可管理的部分. 分区对应用透 ...

  10. 如何在 Mac 上卸载 Java?

    使用终端卸载 Oracle Java 注:要卸载 Java,您必须具有管理员权限,并且必须以 root 用户身份或者使用 sudo 工具来执行删除命令. 按照下面所示,删除一个目录和一个文件(符号链接 ...