【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两种颜色的格子; 让你在这个格子 ...
随机推荐
- Hello World FastCGI
什么是FastCGI,google吧,測试一个用C++实现的FastCGI程序. 1, Nginx 安装.http://nginx.org/en/download.html.下载解压.configur ...
- 几种常见sqlalchemy查询:
#简单查询 print(session.query(User).all()) print(session.query(User.name, User.fullname).all ...
- SPOJ1812: LCS2 - Longest Common Substring II & BZOJ2946: [Poi2000]公共串
[传送门:SPOJ1811&BZOJ2946] 简要题意: 给出若干个字符串,求出这些字符串的最长公共子串 题解: 后缀自动机 这两道题的区别只是在于一道给出了字符串个数,一个没给,不过也差不 ...
- 智课雅思词汇---八、ject是什么意思
智课雅思词汇---八.ject是什么意思 一.总结 一句话总结:词根:ject, jac(jet) = to throw(投掷, 扔) 1.geo是什么意思? 词根:-ge-, -geo- [词根含义 ...
- centos7 安装swftools Apache_OpenOffice
centos7 yum -y install wget wget http://www.swftools.org/swftools-0.9.2.tar.gz tar -xf swftools-.tar ...
- 23.STL容器小结
- POJ 4007 Flood-it!
题目:http://poj.org/problem?id=4007 思路: (lyd学长的思路) IDA*算法,首先迭代加深限制搜索深度. 可以发现如果当前矩阵中除了左上角的连通块之外,共有M种颜色, ...
- 求推荐go语言开发工具及go语言应该以哪种目录结构组织代码?
go语言的开发工具推荐? go语言开发普通程序及开发web程序的时候,应该以哪种目录结构组织代码? 求推荐go语言开发工具及go语言应该以哪种目录结构组织代码? >> golang这个答案 ...
- 《剑指offer》跳台阶
一.题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 二.输入描述 输入n级台阶 三.输出描述 输出总有多少种不同跳法 四.牛客网提供的框架 cla ...
- [转] -- html5手机网站自适应需要加的meta标签
webapp开发初期,会碰到在pc端开发好的页面在移动端显示过大的问题,这里需要在html head中加入meta标签来控制缩放 <meta name=" viewport" ...