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

题目来源

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

题意:

两个人玩游戏 初始分值是m 进行n次操作

每次操作有三种选项 a,b,c

a不为0表示 可以选择加a;b不为0表示 可以选择减b; c不为0表示 可以选择乘-1

分值的上下界是-100和100

一个人希望分值最后大于k 一个人希望分值最后小于l 求最后分值会落在哪个范围

思路:

其实不太会记忆化搜索 本来以为就是dp 但是写了半天写不出来

其实记忆化搜索就是 dfs递归 + dp记录

dfs过程中一旦发现dp数组已经有值了就直接返回 这样对dfs进行了剪枝

用dp[id][x]表示在分值为x时进行第id次操作的结果 1表示先手必胜 0表示平手 -1表示先手必败

根据递归返回的结果 加上当前的局数来判断当前结果

 #include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <cstring>
#include <set>
#include <map> #define inf 0x3f3f3f3f
using namespace std; typedef long long LL; int n, m, l, k;
const int maxn = ;
int dp[maxn][];
struct node{
int a, b, c;
}op[maxn]; int solve(int id, int x)
{
int win, lose, done, tmp;
if(dp[id][x] <= ){
return dp[id][x];
}
if(id == n + ){
if(x >= k) return ;
if(x <= l) return -;
return ;
} win = lose = done = ;
if(id % ){
if(op[id].a != ){
tmp = solve(id + , min(x + op[id].a, ));
if(tmp == ){
win = ;
}
if(tmp == ){
done = ;
}
if(tmp == -){
lose = ;
}
}
if(op[id].b != ){
tmp = solve(id + , max(, x - op[id].b));
if(tmp == ){
win = ;
}
if(tmp == ){
done = ;
}
if(tmp == -){
lose = ;
}
}
if(op[id].c != ){
tmp = solve(id + , - x);
if(tmp == ){
win = ;
}
if(tmp == ){
done = ;
}
if(tmp == -){
lose = ;
}
}
if(win == ){
return dp[id][x] = ;
}
else if(done == ){
return dp[id][x] = ;
}
else{
return dp[id][x] = -;
}
}
else{
if(op[id].a != ){
tmp = solve(id + , min(x + op[id].a, ));
if(tmp == ){
lose = ;
}
if(tmp == ){
done = ;
}
if(tmp == -){
win = ;
}
}
if(op[id].b != ){
tmp = solve(id + , max(, x - op[id].b));
if(tmp == ){
lose = ;
}
if(tmp == ){
done = ;
}
if(tmp == -){
win = ;
}
}
if(op[id].c != ){
tmp = solve(id + , - x);
if(tmp == ){
lose = ;
}
if(tmp == ){
done = ;
}
if(tmp == -){
win = ;
}
}
if(win == ){
return dp[id][x] = -;
}
else if(done == ){
return dp[id][x] = ;
}
else{
return dp[id][x] = ;
}
} } int main()
{
while(scanf("%d%d%d%d", &n, &m, &k, &l) != EOF){
m += ;
l += ;
k += ;
for(int i = ; i <= n; i++){
scanf("%d%d%d", &op[i].a, &op[i].b, &op[i].c);
} //memset(dp, 62, sizeof(dp));
//cout<<dp[0]<<endl;
memset(dp, inf, sizeof(dp));
int ans = solve(, m);
if(ans == ){
printf("Good Ending\n");
}
else if(ans == -){
printf("Bad Ending\n");
}
else{
printf("Normal Ending\n");
}
}
return ;
}

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

题目来源

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. 2018 ICPC 徐州网络赛

    2018 ICPC 徐州网络赛 A. Hard to prepare 题目描述:\(n\)个数围成一个环,每个数是\(0\)~\(2^k-1\),相邻两个数的同或值不为零,问方案数. solution ...

  3. 计蒜客 41391.query-二维偏序+树状数组(预处理出来满足情况的gcd) (The Preliminary Contest for ICPC Asia Xuzhou 2019 I.) 2019年徐州网络赛)

    query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be rep ...

  4. ICPC 2019 徐州网络赛

    ICPC 2019 徐州网络赛 比赛时间:2019.9.7 比赛链接:The Preliminary Contest for ICPC Asia Xuzhou 2019 赛后的经验总结 // 比赛完才 ...

  5. [徐州网络赛]Longest subsequence

    [徐州网络赛]Longest subsequence 可以分成两个部分,前面相同,然后下一个字符比对应位置上的大. 枚举这个位置 用序列自动机进行s字符串的下标转移 注意最后一个字符 #include ...

  6. ACM-ICPC2018徐州网络赛 BE, GE or NE(对抗搜索+博弈+记忆化)

    BE, GE or NE 23.58% 1000ms 262144K   In a world where ordinary people cannot reach, a boy named &quo ...

  7. 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 ...

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

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

  9. 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次操作 ...

随机推荐

  1. imx6dl uboot 移植

    新版的BSP引进的设备树的机制,在uboot中还添加了menuconfig的配置菜单. 参考官网的文档进行uboot移植,本文使用的cpu是imx6dl,uboot版本2015.04. 我要添加一个名 ...

  2. CString常用函数

    转自:http://www.cnblogs.com/Caiqinghua/archive/2009/02/16/1391190.html CString( );例:CString csStr; CSt ...

  3. BMP是在Bean中完成对数据库JDBC的各种调用

    BMP是在Bean中完成对数据库JDBC的各种调用 CMP是由EJB容器自动完成对数据库的操作 会话Bean主要处理业务逻辑

  4. (转)SDL1.2到2.0的迁移指南

    里面有些单词不好翻译所以放在开头,以备查验. BLock Image Transfer, a computer graphics operation in which two bitmap patte ...

  5. 关于Random中的随机数种子Seed

    Random初始化的时候,可以以一个INT32作为参数,称为seed,MSDN上的解释是:“伪随机数是以相同的概率从一组有限的数字中选取的......随机数的生成是从种子值开始......” 所有标准 ...

  6. java反射详解 (转至 http://www.cnblogs.com/rollenholt/archive/2011/09/02/2163758.html)

    本篇文章依旧采用小例子来说明,因为我始终觉的,案例驱动是最好的,要不然只看理论的话,看了也不懂,不过建议大家在看完文章之后,在回过头去看看理论,会有更好的理解. 下面开始正文. [案例1]通过一个对象 ...

  7. xampp更改网站存放目录

    改完后重启xampp 如何更改监听端口8080

  8. Sublime Text2安装Package Control

    一.安装Package Control 使用Sublime Text2首先就要安装Package Control,这样就能使用丰富的插件包了 安装方法有2种: (1)访问Package Control ...

  9. oracle如何将am,pm时间字符串改为时间格式

    问题: 解决办法: 1.param["OPT_DATE"] = DateTime.Parse(dt.Rows[0]["CREATED_ON"].ToString ...

  10. Excel时间格式修改为文本格式