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. C++ 类的隐式转换

    所谓类的隐式转换,就是将实参类型转成形参类型--如果不一致的话. 这个转换与基本类型转换不太一样,具体则是在形参类型的构造函数中使用实参类型的数据,从而构造出一个临时对象. 下面的代码,类Person ...

  2. vs2008 x64编译环境 忽略了 #ifdef WIN32

    解决方法: 右键项目属性,在预处理器中添加WIN32即可 效果:

  3. perl chomp 函数的真正作用

    之前一直以为chomp函数只是去掉字符串末尾的\n, 但是今天写程序遇到一个bug,最后的原因就处在chomp上: 读取fasta文件,内容如下: >1 ATGCTAGCTACGTACGTACG ...

  4. win7cmd静态绑定arp

    netsh -c "172.16.3.1" "f4-ea-67-8b-91-cc"

  5. 用 python 抓取知乎指定回答下的视频

    前言 现在知乎允许上传视频,奈何不能下载视频,好气哦,无奈之下研究一下了,然后撸了代码,方便下载视频保存. 接下来以 猫为什么一点也不怕蛇? 回答为例,分享一下整个下载过程. 调试一下 打开 F12, ...

  6. ubuntu下使用sublime text进行C编程开发尝鲜

    1 选择编译系统 2 编写文件,编译(Ctrl+B)运行(Shift+Ctrl+B)

  7. 07python之字符串的常用方法

    字符串作为python中常用的数据类型,掌握字符串的常用方法十分必要. 常用知识点: 1.字符串的3种格式化方法 2.字符串的strip()方法 3.字符串的join()方法 4.字符串可以切片 1. ...

  8. 【RF库Collections测试】Dictionary Should Not Contain Value

    Name:Dictionary Should Not Contain ValueSource:Collections <test library>Arguments:[ dictionar ...

  9. NGUI屏幕自适应(转)

      屏幕自适应 NGUI可以比较方便的实现屏幕自适应,但是它的官方教程里面针对这个问题没有详细的教程,所以可能在实现的时候会走比较多的弯路.以下是我在开发过程中找到的一个比较方便的实现方法. 主要组件 ...

  10. Unity3d 手机屏幕自动适配

    我提到手机自动适配的一个方法中:postion和Scale,“比例”概念适配手机.原始资源是480*800 经过实际项目考验,个人感觉: 1,UICamera是自动适配分辨率,UI上也是拉伸.放大UI ...