【Codeforces Round #459 (Div. 2) D】MADMAX
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
f[x][y][z][2]
表示第一个人到了点x,第二个人到了点y,当前轮的字母(1..26),当前轮到谁走的情况下,谁赢。
写个记搜就好。
完全是模拟走的过程。。
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int n,m;
vector <pair<int,int> > g[N+10];
int f[N+10][N+10][26+2][2+2];
int dfs(int x,int y,int now,int turn){
if (f[x][y][now][turn]!=-1) return f[x][y][now][turn];
if (turn == 0){
for (auto temp:g[x]){
if (temp.second>=now){
if (dfs(temp.first,y,temp.second,1-turn)==0){
return f[x][y][now][turn] = 0;
}
}
}
return f[x][y][now][turn] = 1;
}else{
for (auto temp:g[y]){
if (temp.second>=now){
if (dfs(x,temp.first,temp.second,1-turn)==1){
return f[x][y][now][turn] = 1;
}
}
}
return f[x][y][now][turn] = 0;
}
}
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
memset(f,255,sizeof f);
cin >> n >> m;
for (int i = 1;i <= m;i++){
int x,y;char s[3];
cin >> x >> y >> s;
g[x].push_back(make_pair(y,s[0]-'a'));
}
for (int i = 1;i <= n;i++){
for (int j = 1;j <= n;j++){
if (dfs(i,j,0,0)==1)
cout<<'B';
else
cout<<'A';
}
cout<<endl;
}
return 0;
}
【Codeforces Round #459 (Div. 2) D】MADMAX的更多相关文章
- 【Codeforces Round #459 (Div. 2) B】 Radio Station
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map模拟一下映射就好了. [代码] #include <bits/stdc++.h> using namespace ...
- 【Codeforces Round #459 (Div. 2) A】Eleven
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 这个数列增长很快的. 直接暴力模拟看看是不是它的一项就好了 [代码] #include <bits/stdc++.h> ...
- 【Codeforces Round #459 (Div. 2) C】The Monster
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 左括号看成1 右括号看成-1 设置l,r表示前i个数的和的上下界 遇到 左括号 l和r同时加1 遇到右括号 同时减1 遇到问号 因为 ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
随机推荐
- mysql-基础和基本指令
基础: 1.数据库模式:简单的说:就是一个数据库用户所拥有的数据库的对象. 比如scott用户建立了表,索引,视图,存储过程等对象,那么这些对象就构成了schema scott .有时用作数据 ...
- Linux下安装Mysql(RPM安装)
一.去官网下载本次安装须要的mysql版本号.我们须要安装的是5.1版本号的且centos系统是64位的.所下面载的是MySQL-community-5.1.73-1.rhel5.x86_64.rpm ...
- Unity游戏开发--30s制作精美地图
"君子生非异也.善假于物也"--<劝学>荀子 引用这句话的目的,是我觉得有时候.利用工具来提高游戏开发效率是很必要的. 利用工具,解放程序员双手. 今天想给大家介绍下. ...
- sql server management studio 快速折叠object explorer中的instance
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/6e20fa7a-c0a9-496b-89b2-19c6bd996ffc/how-to ...
- 熟悉了下HTTP协议
HTML是一种用来定义网页的文本,会HTML,就可以编写网页: HTTP是在网络上传输HTML的协议,用于浏览器和服务器的通信.200表示一个成功的响应,后面的OK是说明.失败的响应有404 Not ...
- The in operator
The operators we have seen so far are all special characters like + and *, but there are a few opera ...
- Ubuntu 18.04 安装 Broadcom Limited BCM43142无线网卡驱动
系统默认没有集成 BCM43142无线网卡驱动可以通过下面的方法安装--------------------------------------------------------------root ...
- ES6学习笔记(十三)Iterator遍历器和for...of循环
1.概念 遍历器(Iterator)就是这样一种机制.它是一种接口,为各种不同的数据结构提供统一的访问机制.任何数据结构只要部署 Iterator 接口,就可以完成遍历操作(即依次处理该数据结构的所有 ...
- BZOJ 3626 LCA(离线+树链剖分+差分)
显然,暴力求解的复杂度是无法承受的. 考虑这样的一种暴力,我们把 z 到根上的点全部打标记,对于 l 到 r 之间的点,向上搜索到第一个有标记的点求出它的深度统计答案.观察到,深度其实就是上面有几个已 ...
- P3514 [POI2011]LIZ-Lollipop(规律+瞎搞)
题意 给一个只有1和2的序列,每次询问有没有一个子串的和为x ( 1≤n,m≤1 000 000 )kkk ( 1≤k≤2 000 000 ) 题解 我觉得是道好题. 主要是证明一个性质:假如有一个字 ...