ACM-ICPC 2018 徐州赛区网络预赛 B. BE, GE or NE

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 徐州赛区网络预赛

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <vector>
 6 #include <queue>
 7 #include <stack>
 8 #include <cstdlib>
 9 #include <iomanip>
10 #include <cmath>
11 #include <cassert>
12 #include <ctime>
13 #include <map>
14 #include <set>
15 #include <vector>
16 using namespace std;
17 #define  ull unsigned  long  long
18 #define ll  long  long
19 #define  ph push_back
20 #define N 1120
21 int a[N],b[N],c[N];
22 int  n,m,l,r;
23 int cnt;
24 int dp[N][250];
25 map<int,int>id;
26 int dfs(int cnt,int now){
27     if(cnt>=n+1){
28         if(now>=r)  return 2;
29         if(now>l)  return 1;//>l
30         return 0;
31     }
32     if(dp[cnt][id[now]]!=-1)  return  dp[cnt][id[now]];
33     //a[cnt],b[cnt],c[cnt]不会同时为0
34     if(cnt&1){
35         int val=0;
36         if(a[cnt]) val=max(val,dfs(cnt+1,min(100,now+a[cnt])));
37         if(b[cnt]) val=max(val,dfs(cnt+1,max(-100,now-b[cnt])));
38         if(c[cnt]) val=max(val,dfs(cnt+1,-now) );//一定在-100 ~100
39         return  dp[cnt][id[now]]=val;
40     }
41     else{
42         int val=2;
43         if(a[cnt]) val=min(val,dfs(cnt+1,min(100,now+a[cnt])));
44         if(b[cnt]) val=min(val,dfs(cnt+1,max(-100,now-b[cnt])));
45         if(c[cnt]) val=min(val,dfs(cnt+1,-now) );
46         return  dp[cnt][id[now]]=val;
47     }
48 }
49 int main()
50 {
51     for(int  i=0;i<N;i++)
52     {
53         for(int j=0;j<210;j++){
54             dp[i][j]=-1;//不可能是0 1 2
55         }
56     }
57     for(int i=-100;i<=100;i++) id[i]=cnt++;
58     scanf("%d%d%d%d",&n,&m,&r,&l);
59     for(int  i=1;i<=n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
60     int val=dfs(1,m);
61     if(val==2) printf("Good Ending\n");
62     else if(val==0) printf("Bad Ending\n");
63     else{
64         printf("Normal Ending\n");
65     }
66     return 0;
67 }

原文地址:https://www.cnblogs.com/tingtin/p/9643284.html

时间: 2024-12-08 14:42:21

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

ACM-ICPC 2018 徐州赛区网络预赛 B. BE, GE or NE &lt;&lt;DP

题意 两个人在一起玩galgame,一个人想看good ending,另一个想看bad ending,两个人轮流选选项都按最优策略选,问最后能看到什么结局. 思路 可以理解为一个人想让最终分数尽可能高,另一个想让最终分数尽可能低,然后根据每个问题双向dp,一下子就写出来了. 代码 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1005; 4 struct selection{ 5 int a,b,c; 6 }; 7

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

链接https://nanti.jisuanke.com/t/31454 思路 开始没读懂题,也没注意看数据范围(1000*200的状态,记忆化搜索随便搞) 用记忆化搜索处理出来每个状态的胜负情况 因为每个人都会选择最优的,因此记忆化搜索的过程其实就是在模拟两个人每一步决策所带来的胜负情况, 只要返回一个必胜,就直接返回(因为会选择最优) 然后在没有返回必胜的状态下,有平局就选择平局,没有平局就只能输了 #include<bits/stdc++.h> #define st 100 #defin

ACM-ICPC 2018 徐州赛区网络预赛 D. EasyMath

ACM-ICPC 2018 徐州赛区网络预赛 D. EasyMath 做法: \[f(m,n) = \sum _{i=1}^{m} \mu(in) = \sum_{i=1}^{m}[gcd(i,n)=1]\mu(i)\mu(n) = \mu(n)\sum_{d|n}\mu(d)f(\frac{m}{d},d)\] 边界: n=1,杜教筛求\(\sum_{i=1}^{m}\mu(i)\),m = 1, 返回\(\mu(n)\),预处理尽可能把空间卡满. 2个小时的时候就推出来了这个式子,不会算复杂

ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn&#39;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 learn, each book has its knowledge a[i]a[i]. Unfortunately, the longer he learns, the fewer he gets. That means, if he reads books from ll to rr, he wi

ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn&#39;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, each book has its knowledge a[i]a[i]. Unfortunately, the longer he learns, the fewer he gets. That means, if he reads books from ll to rr, he will get a

ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer (最大生成树+LCA求节点距离)

ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer master has to do his job. A tour company gives him a map which is a rectangle. The map consists of N \times MN×M little squares. That is to say, the h

ICPC 2018 徐州赛区网络赛

ACM-ICPC 2018 徐州赛区网络赛 ?去年博客记录过这场比赛经历:该死的水题 ?一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进. ? ? D. Easy Math 题意: ? 给定 \(n\), \(m\) ,求 \(\sum _{i=1}^{m} \mu(in)\) .其中 $ 1 \le n \le 1e12$ , $ 1 \le m \le 2e9$ ,\(\mu(n)\) 为莫比乌斯函数. ? 思路: ? 容易知道,\(i\) 与 \(n\) 不互质时, \(\m

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

Rank Solved A B C D E F G H I J K 157/1526 7/11 O O ? ? . O O O O O ? O: 当场通过 ?: 赛后通过 .: 尚未通过 A Hard to prepare solved by chelly chelly's solution B BE, GE or NE solved by ch ch's solution C Cacti Lottery upsolved by chelly chelly's solution 考虑枚举*代表的

ACM-ICPC 2018 徐州赛区网络预赛 A. Hard to prepare

传送门:https://nanti.jisuanke.com/t/31453 本题是一个组合数学(DP,滑稽)题. 一个环上有N个位置,标号为1~N.设第i(1≤i≤N)个位置上的数为x[i],限制条件为:0≤x[i]<2k.另有限制条件:当位置i和位置j相邻时,x[i]⊕x[j]≠2k-1.求满足限制条件的环的状态数. 可以考虑将环切割成链,以分析问题.设: ①a[n]:长度为n,且首尾相同的满足上述条件的链的状态数: ②b[n]:长度为n,且首尾相反的满足上述条件的链的状态数: ③c[n]: