【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

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的更多相关文章

  1. 【Codeforces Round #459 (Div. 2) B】 Radio Station

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map模拟一下映射就好了. [代码] #include <bits/stdc++.h> using namespace ...

  2. 【Codeforces Round #459 (Div. 2) A】Eleven

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 这个数列增长很快的. 直接暴力模拟看看是不是它的一项就好了 [代码] #include <bits/stdc++.h> ...

  3. 【Codeforces Round #459 (Div. 2) C】The Monster

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 左括号看成1 右括号看成-1 设置l,r表示前i个数的和的上下界 遇到 左括号 l和r同时加1 遇到右括号 同时减1 遇到问号 因为 ...

  4. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  5. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  6. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  7. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  8. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  9. 【Codeforces Round #423 (Div. 2) B】Black Square

    [Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...

随机推荐

  1. iOS RegexKitLite 提取匹配的内容

            使用RegexKitLite正则表达式需要以下工作: 1.RegexKitLite官方网址(内含使用教程):http://regexkit.sourceforge.net/RegexK ...

  2. 【POJ 1845】 Sumdiv (整数唯分+约数和公式+二分等比数列前n项和+同余)

    [POJ 1845] Sumdiv 用的东西挺全 最主要通过这个题学了约数和公式跟二分求等比数列前n项和 另一种小优化的整数拆分  整数的唯一分解定理: 随意正整数都有且仅仅有一种方式写出其素因子的乘 ...

  3. hdoj--1301--Jungle Roads(克鲁斯卡尔)

    Jungle Roads Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot ...

  4. [POJ2728] Desert King 解题报告(最优比率生成树)

    题目描述: David the Great has just become the king of a desert country. To win the respect of his people ...

  5. Activity的启动模式和onNewIntent()

    1:首先,在默认情况下,当您通过Intent启到一个Activity的时候,就算已经存在一个相同的正在运行的Activity,系统都会创建一个新的Activity实例并显示出来.为了不让Activit ...

  6. exsi从磁盘中加载虚拟机

    e

  7. 紫书 例题 10-8 UVa 1262 (暴力枚举)

    递归一遍遍历所有情况就ok了 #include<cstdio> #include<cstring> #define REP(i, a, b) for(int i = (a); ...

  8. SP7586 NUMOFPAL - Number of Palindromes(回文树)

    题意翻译 求一个串中包含几个回文串 题目描述 Each palindrome can be always created from the other palindromes, if a single ...

  9. 【转】 HtmlAgilityPack使用——XPath注意事项

    [转] HtmlAgilityPack使用——XPath注意事项 在使用HtmlAgilityPack这个开源的类库进行网页内容解析的时候是非常的方便(使用方法见另一篇博客<HTML解析:基于X ...

  10. Java面向切面原理与实践

    Java面向切面原理与实践 一. 面向切面编程是什么 首先用一句话概括:面向切面编程(AOP)就是对某些具有相似点的代码进行增强. 相似点可以是同一个包.使用相同的注解.public的方法.以Impl ...