https://nanti.jisuanke.com/t/31454

题意

两个人玩游戏,最初数字为m,有n轮,每轮三个操作给出a b c,a>0表示可以让当前数字加上a,b>0表示可以让当前数字减去b,c=1表示可以让当前数字乘-1,数字范围为[-100, 100],如果加/减出范围则直接等于边界,最终结果数字x>=R则为Good Ending,x<=L则为Bad Ending,否则Normal Ending,第一个人希望好结局,第二个人希望坏结局,如果没有办法就希望平局,每个人都做最优选择。求最终结果

分析

一开始题目没看懂啊。。很蒙,然后学弟就秒了。

所以状态1000*200,考虑暴力求解。又是博弈题,那当然是记忆化搜索啦。把每个状态都搜一下,优先选赢,其次才是平局,最后才是输。

因为分数可能为负数,所以这里加了个115变成正数来计算,方便得多。

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mod 1000000007
int n, L, R, dp[][];
typedef struct Res{
int x, y, z;
}Res;
Res s[];
int Go(int x, int y, int t=){
if(x==) y = min(y+t, );
else if(x==) y = max(y-t, );
else y += *(-y);
return y;
}
int dfs(int id, int x){
int win, lose, done, temp;
if(dp[id][x]<=)
return dp[id][x];
if(id==n+){
if(x>=R) return ;
if(x<=L) return -;
return ;
}
win = lose = done = ;
if(id%){//先手,想造出GoodEnding
if(s[id].x!=){
temp = dfs(id+, Go(, x, s[id].x));
if(temp==) win = ;
if(temp==) done = ;
if(temp==-) lose = ;
}
if(s[id].y!=){
temp = dfs(id+, Go(, x, s[id].y));
if(temp==) win = ;
if(temp==) done = ;
if(temp==-) lose = ;
}
if(s[id].z!=){
temp = dfs(id+, Go(, x));
if(temp==) win = ;
if(temp==) done = ;
if(temp==-) lose = ;
}
if(win) return dp[id][x] = ;
else if(done) return dp[id][x] = ;
else return dp[id][x] = -;
}else{
if(s[id].x!=){
temp = dfs(id+, Go(, x, s[id].x));
if(temp==) lose = ;
if(temp==) done = ;
if(temp==-) win = ;
}
if(s[id].y!=){
temp = dfs(id+, Go(, x, s[id].y));
if(temp==) lose = ;
if(temp==) done = ;
if(temp==-) win = ;
}
if(s[id].z!=){
temp = dfs(id+, Go(, x));
if(temp==) lose = ;
if(temp==) done = ;
if(temp==-) win = ;
}
if(win) return dp[id][x] = -;
else if(done) return dp[id][x] = ;
else return dp[id][x] = ;
}
}
int main(){
int ans, m, i;
scanf("%d%d%d%d", &n, &m, &R, &L);
R += , L += ;
for(i=;i<=n;i++)
scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].z);
memset(dp, , sizeof(dp));
ans = dfs(, m+);
if(ans==) puts("Good Ending");
else if(ans==-) puts("Bad Ending");
else puts("Normal Ending");
return ;
}

ACM-ICPC 2018 徐州赛区网络预赛 B BE, GE or NE(记忆化搜索)的更多相关文章

  1. ACM-ICPC 2018 徐州赛区网络预赛 B. BE, GE or NE

    In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named &qu ...

  2. ACM-ICPC 2018 徐州赛区网络预赛 B BE, GE or NE(博弈,记忆化搜索)

    链接https://nanti.jisuanke.com/t/31454 思路 开始没读懂题,也没注意看数据范围(1000*200的状态,记忆化搜索随便搞) 用记忆化搜索处理出来每个状态的胜负情况 因 ...

  3. ACM-ICPC 2018 徐州赛区网络预赛 B BE, GE or NE 【模拟+博弈】

    题目:戳这里 题意:A和B博弈,三种操作分别是x:加a,y:减b,z:取相反数.当x或y或z为0,说明该操作不可取,数据保证至少有一个操作可取,给定一个区间(l,k)和原始数字m,如果A和B在n次操作 ...

  4. ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心)

    ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心) Trace 问答问题反馈 只看题面 35.78% 1000ms 262144K There's a beach in t ...

  5. ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer (最大生成树+LCA求节点距离)

    ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer ...

  6. 计蒜客 1460.Ryuji doesn't want to study-树状数组 or 线段树 (ACM-ICPC 2018 徐州赛区网络预赛 H)

    H.Ryuji doesn't want to study 27.34% 1000ms 262144K   Ryuji is not a good student, and he doesn't wa ...

  7. ACM-ICPC 2018 徐州赛区网络预赛 B(dp || 博弈(未完成)

    传送门 题面: In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl n ...

  8. ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn't want to study

    262144K   Ryuji is not a good student, and he doesn't want to study. But there are n books he should ...

  9. ACM-ICPC 2018 徐州赛区网络预赛 F. Features Track

    262144K   Morgana is learning computer vision, and he likes cats, too. One day he wants to find the ...

随机推荐

  1. it's time to change myself now (2018.10.31)

    自16年从新屋熊职校毕业,入职深圳某厂从事云存储两年半了.两年半的时间很快,快的感觉一生都会飞快,两年多一直很忙,忙的几乎忘了自己是否正向改变过. 正向改变,or 积极改变,今年十一回家,与几个好友小 ...

  2. gradlew和gradle的区别

    概念理解 gradlew就是对gradle的包装和配置,gradlew是gradle Wrapper,Wrapper的意思就是包装. 因为不是每个人的电脑中都安装了gradle,也不一定安装的版本是要 ...

  3. kernel笔记——内核编译与进程管理

    内核与操作系统 由于一些商业操作系统设计上的缺陷以及日益庞杂,“操作系统”的概念对很多人而言变得含糊不清.在进一步讨论Linux内核的话题前,我们先区分“内核”与“操作系统”这两个概念. 操作系统:指 ...

  4. 完成一个java项目需要的一些基础

    包括  1.eclipse关键字      2.文档注      3. jar包的导出与导入 一.elipse关键字 ctry+t       查看父类 ctry+鼠标光标     查看源代码 二.文 ...

  5. java中 & ^ ~ 的运算

    java运算符 与(&).非(~).或(|).异或(^)   最近看HashMap源码,遇到了这样一段代码: 1 static final int hash(Object key) { 2 i ...

  6. Jenkins持续集成实践之java项目自动化部署

    关于Linux安装Jenkins可以参考我的这篇博文Ubuntu16.04环境安装jenkins 1.安装部署插件 进入插件管理,并搜索该插件Deploy to container Plugin进行安 ...

  7. Hive中知识点

    hive的最新学习资料:http://www.cnblogs.com/qingyunzong/p/8707885.html hive的参数设置大全:https://cwiki.apache.org/c ...

  8. vue diff 算法学习

    function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { let oldStartIdx ...

  9. IdentityServer4【Reference】之Profile Service

    Profile Service 当创建令牌或者请求像Userinfo这种端点时,IdentityServer通常会需要用户的标识信息(identity information),默认情况下,Ident ...

  10. idea的一些好用的第三方插件

    用了Idea真的回不去Eclipse了,安利一波. 这里记录一些好用的插件. GenerateAllSetter 这个插件是用在写代码的时候调用Setter的时候能一次性把实体类中的所有Setter方 ...