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-3options, 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 .

That is, if there are three options in a selection, the score will be increased by 1, decreased by 1, or multiplied by −1. The score before the selection is 8. 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 100 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,l( 10001≤n≤1000, −100≤m≤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≥0 ,b≥0 ,c=0 or c=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

题目来源

ACM-ICPC 2018 徐州赛区网络预赛

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define ph push_back
int n,m,l,r;
#define N 1009
int a[N],b[N],c[N];
map<int,map<int,int> >mp;
void init()
{
for(int i=;i<N;i++)
{
for(int j=-;j<;j++)//-120到120
{
mp[i][j]=-;//要小于0
}
}
}
//先手想要最后的结果尽量大,而后手希望最后的结果尽量小
int dfs(int cnt,int now){//cnt 次数,now 当前的得分
if(cnt>=n+){
if(now>=r) return ;
if(now>l) return ;
return ;
}
if(mp[cnt][now]!=-) return mp[cnt][now];
if(cnt&){
int val=;
if(a[cnt]) val=max(val,dfs(cnt+,min(,now+a[cnt])) );
if(b[cnt]) val=max(val,dfs(cnt+,max(-,now-b[cnt])) );
if(c[cnt]) val=max(val,dfs(cnt+,-now));
return mp[cnt][now]=val;
}
else{
int val=;
if(a[cnt]) val=min(val,dfs(cnt+,min(,now+a[cnt])) );
if(b[cnt]) val=min(val,dfs(cnt+,max(-,now-b[cnt])) );
if(c[cnt]) val=min(val,dfs(cnt+,-now) );
return mp[cnt][now]=val;
}
}
int main()
{
scanf("%d%d%d%d",&n,&m,&r,&l);//刚开始输成了l,r.
for(int i=;i<=n;i++)//要从1开始
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
}
init();
int val=dfs(,m);
if(val==){
printf("Good Ending\n");
}
else if(val==){
printf("Normal Ending\n");
}
else{
printf("Bad Ending\n");
}
return ;
}

ACM-ICPC 2018 徐州赛区网络预赛 B. BE, GE or NE的更多相关文章

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

    https://nanti.jisuanke.com/t/31454 题意 两个人玩游戏,最初数字为m,有n轮,每轮三个操作给出a b c,a>0表示可以让当前数字加上a,b>0表示可以让 ...

  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. [RDL]中多行组列组占比报表制作

    结果如下: 生意额占比表达式:=iif(Fields!生意额.Value is nothing,"",Fields!生意额.Value/sum(Fields!生意额.Value, ...

  2. 牛客网Java刷题知识点之什么是内部类、为什么要使用内部类、内部类如何使用外部类的属性和方法、成员内部类、局部内部类、静态内部类、匿名内部类

    不多说,直接上干货! 可以将一个类的定义放在另一个类的定义内部,这就是内部类. 内部类是一个非常有用的特性但又比较难理解使用的特性(鄙人到现在都没有怎么使用过内部类,对内部类也只是略知一二). 内部类 ...

  3. 啊哈算法之宽搜BFS解救小哈

    简述 本算法摘选自啊哈磊所著的<啊哈!算法>第四章第三节的题目——BFS算法再次解救小哈.文中代码使用C语言编写,博主通过阅读和理解,重新由Java代码实现了一遍,以此来理解BFS算法.关 ...

  4. JavaWeb_05_xml相关&dtd快速入门

    学东西怎么学,是什么,能做什么,怎么去做!! 1.xml的简介 1.eXtensible Markup Language:可扩展标记型语言 标记型语言:html是标记型语言 也是使用标签来操作 可扩展 ...

  5. C# 报表和打印等

    说到报表打印.那就不得不说需要查数据库了,然后填写报表信息.设计报表用的 grid++. 查数据库时候,我也是醉了,直接一个表自身与自身级联了4次...一共取了7个表的信息数据. 关于级联--(表字段 ...

  6. 【extjs6学习笔记】1.5 初始:关于布局

    absolute 绝对布局,这个布局使用 x 和 y 属性来指定组件的绝对定位 accordion 手风琴布局[可折叠布局]这个布局展示了在一个时间里只有一个内置的可支持折叠和展开的子级 panel ...

  7. BLL-IDAL-DAL的关系

    BLL  实现 IDAL  是一个接口 DAL 实现方法 BLL 调用IDAL 的方法 IDAL中的方法   在 DAL中必须实现 使用的方法  调用BLL的方法就可以

  8. JavaScript_5_对象

    1. JavaScrip中所有事物都是对象:字符串.数字.日期.等等 2. 在javaScripe中,对象是拥有属性和方法的数据 <!DOCTYPE html> <html> ...

  9. MovieReview—Despicable Me 3(神偷奶爸3)

    Minions&Unicorn         The film focuses on the story of Grew and the bastard Bled. A variety of ...

  10. Iterator中的next()

    DBExchangeMoney类: 1 package com.ch.test15; import java.sql.DriverManager; import java.sql.ResultSet; ...