BE, GE or NE

  • 23.58%
  • 1000ms
  • 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复制

  1. 3 -8 5 -5
  2. 3 1 1
  3. 2 0 1
  4. 0 2 1

样例输出1复制

  1. Good Ending

样例输入2复制

  1. 3 0 10 3
  2. 0 0 1
  3. 0 10 1
  4. 0 2 1

样例输出2复制

  1. Bad Ending

题目来源

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

  1. #include<bits/stdc++.h>
  2. #define MAX 1005
  3. #define INF 0x3f3f3f3f
  4. #define MOD 1000000007
  5. using namespace std;
  6. typedef long long ll;
  7.  
  8. int a[MAX],b[MAX],c[MAX];
  9. int dp[MAX][];
  10. int n;
  11. int dfs(int pos,int now)
  12. {
  13. if(pos>n) return now;
  14. if(dp[pos][now+]!=INF) return dp[pos][now+];
  15. if(pos&){
  16. int x=-INF;
  17. if(a[pos]) x=max(x,dfs(pos+,min(now+a[pos],)));
  18. if(b[pos]) x=max(x,dfs(pos+,max(now-b[pos],-)));
  19. if(c[pos]) x=max(x,dfs(pos+,-now));
  20. dp[pos][now+]=x;
  21. }
  22. else{
  23. int x=INF;
  24. if(a[pos]) x=min(x,dfs(pos+,min(now+a[pos],)));
  25. if(b[pos]) x=min(x,dfs(pos+,max(now-b[pos],-)));
  26. if(c[pos]) x=min(x,dfs(pos+,-now));
  27. dp[pos][now+]=x;
  28. }
  29. return dp[pos][now+];
  30. }
  31. int main()
  32. {
  33. int t,m,head,tail,i,j;
  34. while(~scanf("%d%d%d%d",&n,&m,&head,&tail)){
  35. for(i=;i<=n;i++){
  36. scanf("%d%d%d",&a[i],&b[i],&c[i]);
  37. }
  38. memset(dp,INF,sizeof(dp));
  39. int ans=dfs(,m);
  40. if(ans>=head) printf("Good Ending\n");
  41. else if(ans<=tail) printf("Bad Ending\n");
  42. else printf("Normal Ending\n");
  43. }
  44. return ;
  45. }

ACM-ICPC2018徐州网络赛 BE, GE or NE(对抗搜索+博弈+记忆化)的更多相关文章

  1. 2018 ICPC 徐州网络赛

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

  2. 计蒜客 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 ...

  3. ICPC 2019 徐州网络赛

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

  4. [徐州网络赛]Longest subsequence

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

  5. 徐州网络赛B-BE,GE or NE【记忆化搜索】【博弈论】

    In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named &qu ...

  6. 徐州网络赛A-Hard To Prepare【dp】【位运算】【快速幂】

    After Incident, a feast is usually held in Hakurei Shrine. This time Reimu asked Kokoro to deliver a ...

  7. 徐州网络赛J-Maze Designer【最小生成树】【LCA】

    After the long vacation, the maze designer master has to do his job. A tour company gives him a map ...

  8. 徐州网络赛G-Trace【线段树】

    There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy  ...

  9. 徐州网络赛H-Ryuji doesn't want to study【线段树】

    Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, ea ...

随机推荐

  1. Spring Boot:Thymeleaf篇

    Spring Boot干货系列:(四)Thymeleaf篇http://www.cnblogs.com/zheting/p/6707037.html 前言 Web开发是我们平时开发中至关重要的,这里就 ...

  2. Linux入门基础(三)——系统命令

  3. logback 配置详解(上)

    logback 配置详解(一)<configuration> and <logger> 一:根节点<configuration>包含的属性: scan: 当此属性设 ...

  4. Laravel5.5执行表迁移命令出现表为空的解决方案

    今天在使用一个第三方包 laravel-admin 时,出现了这样的错误:SQLSTATE[42000]: Syntax error or access violation: 1103 Incorre ...

  5. linux字符设备学习笔记【原创】

    1.申请设备号 int register_chrdev_region(dev_t from, unsigned count, const char *name) 指定从设备号from开始,申请coun ...

  6. iOS SDK:iOS调试技巧

    感谢原创 在程序中,无论是你想弄清楚为什么数组中有3个对象而不是5个,或者为什么一个新的玩家开始之后,游戏在倒退——调试在这些处理过程中是比较重要的一部分.通过本文的学习,我们将知道在程序中,可以使用 ...

  7. SpringBoot2.0之整合ActiveMQ(点对点模式)

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. ffmpeg给视频加文字水印

    ffmpeg -i dd2800.mp4 -vf "drawtext=fontfile=Arial.ttf: text='Hu':x=100:y=10:fontsize=24:fontcol ...

  9. the art of seo(chapter eight)

    How Social Media and User Data Play a Role in Search Results and Rankings ***Correlation Between Soc ...

  10. redis实现分布式锁——核心 setx+pipe watch监控key变化-事务

    如何设计一把分布式锁 我们用 redis 来实现这把分布式的锁,redis 速度快.支持事务.可持久化的特点非常适合创建分布式锁. 分布式环境中如何消除网络延迟对锁获取的影响 锁,简单来说就是存于 r ...