题意

题目链接

很难概括。。

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. SAP CRM settype的创建,背后发生了什么

    来自我的同事Sara. 当我们在CRM系统里创建一个settype之后,其实系统后台悄悄的帮我们创建了很多ABAP对象,比如对应的database tables, other ABAP Diction ...

  2. 018os模块

    import   osprint(os.getcwd())   # 获取当前目录  F:\python_code\fullstack_s2\week4\day18 os.chdir(r'C:/User ...

  3. 高CPU业务

    高CPU业务 Gearman是当年LiveJournal用来做图片resize的,大家也明白图片resize是一个高CPU的操作,如果让web网站去做这个高CPU的功能,有可能会拖垮你的 web应用, ...

  4. FZU-1759 Super A^B mod C---欧拉降幂&指数循环节

    题目链接: https://cn.vjudge.net/problem/FZU-1759 题目大意: 求A^B%C 解题思路: 注意,这里long long需要用%I64读入,不能用%lld #inc ...

  5. BZOJ2333:[SCOI2011]棘手的操作(Splay)

    Description 有N个节点,标号从1到N,这N个节点一开始相互不连通.第i个节点的初始权值为a[i],接下来有如下一些操作: U x y: 加一条边,连接第x个节点和第y个节点 A1 x v: ...

  6. Network Security Threats

    Network Security Combination of low-cost powerful computing and high-performance networks is a two-e ...

  7. Gradle Goodness: Unpacking an Archive

    To create an archive with Gradle is easy. We have several tasks like Zip, Tar, Jar, War and Ear to c ...

  8. php编程零基础如何快速入门。门头沟编程

    昨天遇到一个人,说知道thinktphp,不过几年前的事了. 我先跟他讲了下,xyhcms后台功能,各个版块,以及数据库都介绍了一下. 跟他说了一个功能现场实现,说了实现方法. 然后上机操作,发现他表 ...

  9. OSMboxPost()

    1.向邮箱发送一则消息 2.原型:INT8U OSMboxPost(OS_EVENT *pevent, void *msg) 3. pevent: 消息邮箱指针(ECB指针) msg:   消息指针 ...

  10. 如何搭建私人的ghost博客

    可参考 http://blog.pandax.me/cjbk/ 此文