[BZOJ4801]打牌 博弈搜索
来源:互联网 发布:windows桌面文件丢失 编辑:程序博客网 时间:2024/05/06 00:52
出题人qqq说,分类讨论是大坑
实力作死写了一发分类讨论,发现真tm是大坑
博弈搜索多好啊
#include <bits/stdc++.h>#define INF 2147483647using namespace std;inline int rd() { int r; scanf("%d",&r); return r; }char s[10],t[10];int a,b,c,d,A,B,C,D,x[10];int get() { scanf("%s",s+1); if (s[1] == 'A') return 1; if (s[1] == 'T') return 10; if (s[1] == 'J') return 11; if (s[1] == 'Q') return 12; if (s[1] == 'K') return 13; return s[1]-'0';}int calc(int x,int y,int xh) { if (x == y) { if (xh) return x; else return -x; } if (x == 1) return 1; if (y == 1) return -1; if (x>=y) return x; else return -y;}int o(int x,int y,int xh) { if (x == y) return xh; if (x == 1) return 1; if (y == 1) return 0; if (x>=y) return 1; else return 0;}int dfs(int u,int dep,int v,int xxx) { int ret; if (u == 1 && dep == 3) return v; if (u == 1) { ret = -INF; if (!A) { x[dep] = a, A = 1; ret = max(ret, dfs(0,dep,v,xxx)); x[dep] = 0, A = 0; } if (!B) { x[dep] = b, B = 1; ret = max(ret, dfs(0,dep,v,xxx)); x[dep] = 0, B = 0; } return ret; } if (u == 0) { ret = INF; if (!C) { C = 1; int no = o(x[dep], c, xxx); ret = min(ret, dfs(1,dep+1,v+calc(x[dep],c,xxx),no)); C = 0; } if (!D) { D = 1; int no = o(x[dep], d, xxx); ret = min(ret, dfs(1,dep+1,v+calc(x[dep],d,xxx),no)); D = 0; } return ret; } assert(0); return 0;}int main() { int T = rd(); while (T--) { a = get(), b = get(); if (a>b) swap(a,b); c = get(), d = get(); if (c>d) swap(c,d); int ans = dfs(1,1,0,1); printf("%d\n",ans); } return 0;}
0 0
- [BZOJ4801]打牌 博弈搜索
- 打牌
- 打牌
- 打牌
- 打牌
- BZOJ4801(模拟)
- 搜索——博弈搜索
- POJ 1085 博弈-搜索
- hdoj 4753 博弈+搜索
- 博弈 敌对搜索
- 博弈搜索中的记忆化
- POJ1143(博弈+记忆化搜索)
- Zoj 3591 Nim 【博弈】【搜索】
- 博弈搜索练习-BFS&DFS
- 出去打牌
- 打牌心得
- 1049: 打牌
- 问题 : 打牌
- IMWeb训练营作业-Select
- 自动拍照扫描识别身份证信息SDK
- 读《愿天堂就是书店的模样》
- c++操作mysql
- API Guide:APP组件-应用小部件主机
- [BZOJ4801]打牌 博弈搜索
- React-Router4.0路由中文文档api
- 使用Kaptcha进行验证码的生成和验证
- Note On <High Performance JavaScript>
- Android开发之横竖屏任意切换
- 指定查询
- Tex Quotes, UVa 272
- Synopsys dc-2010-sp5-3安装过程(上)
- 归并排序是一种怎么样的体验