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. RHEL/Centos7 安装图形化桌面(转)

    RHEL/Centos7 安装图形化桌面   Linux是一个多任务的多用户的操作系统,好多linux爱好者在安装完linux后经常遇到一个问题——没有图形化桌面.今天小编在安装RHEL7的时候,一步 ...

  2. Django REST framework基础:版本控制

    DRF的版本控制 为什么需要版本控制 API 版本控制允许我们在不同的客户端之间更改行为(同一个接口的不同版本会返回不同的数据). DRF提供了许多不同的版本控制方案. 可能会有一些客户端因为某些原因 ...

  3. 爬虫系列二(数据清洗--->bs4解析数据)

    一 BeautifulSoup解析 1 环境安装 - 需要将pip源设置为国内源,阿里源.豆瓣源.网易源等 - windows (1)打开文件资源管理器(文件夹地址栏中) (2)地址栏上面输入 %ap ...

  4. Luogu P5296 [北京省选集训2019]生成树计数

    Luogu P5296 [北京省选集训2019]生成树计数 题目链接 题目大意:给定每条边的边权.一颗生成树的权值为边权和的\(k\)次方.求出所有生成树的权值和. 我们列出答案的式子: 设\(E\) ...

  5. R语言学习——因子

    变量可分为名义型变量.有序型变量或者连续型变量.名义型变量是没有顺序之分的类别变量,如糖尿病类型Diabetes(Type1.Type2),即使在数据中Type1编码为1而Type2编码为2,这也并不 ...

  6. CentOS下部署Redis集群

    一.部署环境 服务器三台: 10.10.15.41(配置运行两个实例,端口:6379,6380) 10.10.15.42(配置运行两个实例,端口:6381,6382) 10.10.15.43(配置运行 ...

  7. exgcd

    int exgcd(int a,int b,int &x,int &y){ if (b==0){ x=1,y=0; return a; } int d=exgcd(b,a%b,y,x) ...

  8. VS2017 安装Swagger初步认识

    1.安装NuGet包 2.配置 3.运行测试 参考博客:https://www.cnblogs.com/yilezhu/p/9241261.html 一 安装NuGet包 包名:Swashbuckle ...

  9. linux查询日志常用命令,经常更新

    1.grep命令 grep -c "查询内容" filename    ------c,是小写,可以知道你要查询的内容在这个文件中是否存在 grep -C 10 "查询内 ...

  10. hadoop 集群 master datanode 没有启动

    2018-02-07 02:47:50,377 WARN org.apache.hadoop.hdfs.server.common.Storage: java.io.IOException: Inco ...