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. 使用jquery实现选项卡切换效果

    几张简陋的框架效果图 页面加载时: 选项卡操作后: css样式: <style type="text/css"> *{margin:0px;padding:0px;} ...

  2. wxPython的简单应用

  3. GO语言学习笔记(一)

    GO语言学习笔记 1.数组切片slice:可动态增长的数组 2.错误处理流程关键字:defer panic recover 3.变量的初始化:以下效果一样 `var a int = 10` `var ...

  4. 周末班:Python基础之并发编程

    进程 相关概念 进程 进程(Process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础.在早期面向进程设计的计算机结构中,进程是程序的基本 ...

  5. RabbitMQ基本示例,轮询机制,no_ack作用

    一.RabbitMQ简介: ''' RabbitMQ就是消息队列 之前不是学了Queue了吗,都是队列还学RabbitMQ干嘛? 干的事情是一样的 Python的Queue有两个, 一个线程Queue ...

  6. luffy项目后台drf搭建(1)

    一 进入虚拟环境 打开crm,输入命令 workon luffy 虚拟环境使用文档 二 安装基本类库 pip install django pip install PymySQL pip instal ...

  7. How-to: Do Real-Time Log Analytics with Apache Kafka, Cloudera Search, and Hue

    Cloudera recently announced formal support for Apache Kafka. This simple use case illustrates how to ...

  8. c# 日期函数DateTime.ToString()日期的各种格式

    //c# datetime 格式化 DateTime dt = DateTime.Now; //2017/11/14 10:46:56 label1.Text = dt.ToString();//20 ...

  9. docker面试整理

    为什么要使用docker  https://www.cnblogs.com/AshOfTime/p/10755479.html docker的使用场景 docker和虚拟机比较的优势   https: ...

  10. 011_python常用查询

    一.获取指定日期的后(前)一(n)天 # coding=utf-8 import datetime #获取今天日期(年-月-日) today = datetime.date.today() #< ...