2018徐州网络赛B题 BE, GE or NE (博弈记忆化搜索)

题目链接:https://nanti.jisuanke.com/t/31454

  •  262144K

In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named "Sena" are playing a video game. The game system of this video game is quite unique: in the process of playing this game, you need to constantly face the choice, each time you choose the game will provide 1-31−3 options, the player can only choose one of them. Each option has an effect on a "score" parameter in the game. Some options will increase the score, some options will reduce the score, and some options will change the score to a value multiplied by -1−1 .

That is, if there are three options in a selection, the score will be increased by 11, decreased by 11, or multiplied by -1−1. The score before the selection is 88. Then selecting option 11 will make the score become 99, and selecting option 22 will make the score 77 and select option 33 to make the score -8−8. Note that the score has an upper limit of 100100 and a lower limit of -100−100. If the score is 9999 at this time, an option that makes the score +2+2 is selected. After that, the score will change to 100100 and vice versa .

After all the choices have been made, the score will affect the ending of the game. If the score is greater than or equal to a certain value kk, it will enter a good ending; if it is less than or equal to a certain value ll, it will enter the bad ending; if both conditions are not satisfied, it will enter the normal ending. Now, Koutarou and Sena want to play the good endings and the bad endings respectively. They refused to give up each other and finally decided to use the "one person to make a choice" way to play the game, Koutarou first choose. Now assume that they all know the initial score, the impact of each option, and the kk, ll values, and decide to choose in the way that works best for them. (That is, they will try their best to play the ending they want. If it's impossible, they would rather normal ending than the ending their rival wants.)

Koutarou and Sena are playing very happy, but I believe you have seen through the final ending. Now give you the initial score, the kk value, the ll value, and the effect of each option on the score. Can you answer the final ending of the game?

Input

The first line contains four integers n,m,k,ln,m,k,l(1\le n \le 10001≤n≤1000, -100 \le m \le 100−100≤m≤100 , -100 \le l < k \le 100−100≤l<k≤100), represents the number of choices, the initial score, the minimum score required to enter a good ending, and the highest score required to enter a bad ending, respectively.

Each of the next nn lines contains three integers a,b,ca,b,c(a\ge 0a≥0 , b\ge0b≥0 ,c=0c=0 or c=1c=1),indicates the options that appear in this selection,in which a=0a=0 means there is no option to increase the score in this selection, a>0a>0 means there is an option in this selection to increase the score by aa ; b=0b=0 means there is no option to decrease the score in this selection, b>0b>0 means there is an option in this selection to decrease the score by bb; c=0c=0 means there is no option to multiply the score by -1−1 in this selection , c=1c=1 means there is exactly an option in this selection to multiply the score by -1−1. It is guaranteed that a,b,ca,b,c are not equal to 00 at the same time.

Output

One line contains the final ending of the game. If it will enter a good ending,print "Good Ending"(without quotes); if it will enter a bad ending,print "Bad Ending"(without quotes);otherwise print "Normal Ending"(without quotes).

样例输入1复制

3 -8 5 -5
3 1 1
2 0 1
0 2 1

样例输出1复制

Good Ending

样例输入2复制

3 0 10 3
0 0 1
0 10 1
0 2 1

样例输出2复制

Bad Ending

 

题意就是两个人轮流进行n轮操作 每轮选三种操作中的一个 增加 减少 取反  一个尽可能让分数高 另一个尽可能让分数低

给你l,r判断最后分数的好坏 

拿到这道题一看是个博弈 我们队博弈没人搞 自己又yy觉得跟博弈dp很像 就被自己带偏了 因为数据量小能够暴力也想到了记忆化搜索 偏偏dp记录的值不简单记录最后的结果 死磕状态的期望值 结果死到了比赛结束

这类还是跟博弈dp有点差别的 博弈dp两个人的操作是相同的 目的也相同 而这道题并不是这样 只能记忆化搜索

如果当前好人面对的全是最终分数是坏的选择 那他面临的状态必然是坏的 反之亦然

如果当前好人面临不全是坏的 一旦有一个是好局面 那他一定选好的 如果没有好局面 存在一个中等局面 那他一定选中等的 

如此一来分类讨论一下就出来了 反之亦然

#include <bits/stdc++.h>
using namespace std;
#define py 150
struct xjy
{
    int a,b,c;
}s[1111];
int dp[1111][333];
int n,m,l,r;
int dfs(int now,int sco)
{
    if(now>n)
    {
        if(sco<=l)
            return -1;
        else if(sco>=r)
            return 1;
        else
            return 0;
    }
    if(dp[now][sco+py]!=3)
        return dp[now][sco+py];
    int a=2,b=2,c=2;
    if(s[now].a)
        a=dfs(now+1,min(100,sco+s[now].a));
    if(s[now].b)
        b=dfs(now+1,max(-100,sco-s[now].b));
    if(s[now].c)
        c=dfs(now+1,-sco);
    if((a==1||b==1||c==1)&&(now&1))
    {
        dp[now][sco+py]=1;
        return 1;
    }
    else if((a==-1||b==-1||c==-1)&&((now&1)==0))
    {
        dp[now][sco+py]=-1;
        return -1;
    }
    else if(((a==-1||a==2)&&(b==-1||b==2)&&(c==-1||c==2))&&(now&1))
    {
        dp[now][sco+py]=-1;
        return -1;
    }
    else if((a==1||a==2)&&(b==1||b==2)&&(c==1||c==2)&&((now&1)==0))
    {
        dp[now][sco+py]=1;
        return 1;
    }
    else
    {
        dp[now][sco+py]=0;
        return 0;
    }

}
int main()
{
    while(~scanf("%d%d%d%d",&n,&m,&r,&l))
    {
        for(int i=0;i<1111;i++)
        {
            for(int j=0;j<333;j++)
                dp[i][j]=3;
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&s[i].a,&s[i].b,&s[i].c);
        }
        int ans=dfs(1,m);
        if(ans==1)
            printf("Good Ending\n");
        else if(ans==0)
            printf("Normal Ending\n");
        else
            printf("Bad Ending\n");
    }
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值