| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12392 | Heatstroke Bamboo Rats 2 |
|
| 12435 | Go Down Chicken |
|
| 12463 | I'm calculator |
|
Description
This bamboo rat seems to have heatstroke, we might as well ......
── Brothers HuaNong
Brothers HuaNong feed a lot of bamboo rats. They do love to eat bamboo rats! However, some of the rats seems to have heatstroke. Brothers HuaNong couldn't bear to watch them suffer, and we all know how Brothers HuaNong treat those heatstroke rats...

Every bamboo rat has its level of heatstroke(中暑程度), Brother HuaNong would randomly choose a number . If there's a rat with level of heatstroke equals to , Brother HuaNong would think that the rat has heatstroke and eat it.
However, if they just keep eating those heatstroke rats, they would eat up all the rats eventually, so they also have to buy bamboo rats in case that too many rats have heatstroke.
You are hired by Brothers HuaNong. Brothers HuaNong will give you the level of heatstroke of every bamboo rats and several numbers . Your task is to help them find out if there's rats that have heatstroke.
This problem is partial judge. You are going to implement the following functions:
-
void build_tree(Node **now, int *arr, int l, int r)When this function is called, you should build a binary search tree by the array
arr. -
int query_heatstroke(Node *now, int x)This function is used to ask if there exists a node with level equals to x.
-
void eat_rat(Node **root, int x)This function will delete one node with level equals to x.
-
void buy_rat(Node **root, int x)This function will insert a node with level equals to x.
Take sample as an example, initially, the level of heatstroke of the rats would be (1, 8, 309).
heatstroke 8: Exists a rat with level 8, eat it. The sequence becomes (1, 309).heatstroke 8: No rat with level 8. No dinner tonight.heatstroke 1: Exists a rat with level 1, eat it. The sequence becomes (309).heatstroke 309: Exists a rat with level 309, eat it. The sequence is now empty.buy 5: Add a new rat with level 5. The sequence becomes (5).heatstroke 5: Exists a rat with level 5, eat it. The sequence is now empty.
Input
The first line is an integer n, which indicates the number of bamboo rats.
The next line contains integers, indicate the level of heatstroke of every bamboo rat sorted in ascending order.
The third line is an integer q, which means there are queries below.
There are lines below.
In each queries, there are two operations:
heatstroke x: eat a rat with level equals to if there exists one.buy x: buy a rat with level equals to x.
0 <= n <= 10^4, 1<= q <= 10^4, 1<= x <= 10^9, the level of bamboo rats have the same range as x.
Output
For each heatstroke operation, output "We might as well eat it." if there's a rat with the corresponding level, otherwise output "No dinner tonight."
Sample Input Download
Sample Output Download
Partial Judge Code
12392.cPartial Judge Header
12392.hTags
Discuss
Description
"Go Down Chicken is a vicious monster, it will hit you until you have cerebral concussion(腦震盪)." ~from an anonymous bestiary.
To avoid from being attacked by Go Down Chicken, you need to solve the following problem.
This question has multiple input in each testcase. The input end with EOF.
Each input contain n numbers ai(1 <= i <= n) and q queries xj(1 <= j <= q).
Each number ai represents a game.
The game is that you need to fill a 3 * ai tiles with the shape(The left one) described in the picture below.
The shape can't overlap and no empty space allow. For each ai you need to calculate how many ways you can fill the tiles.
The number of ways may be very large, therefore you need to mod the answer with 1000000007.
For example:
The picture above present a 3*6 tiles, you will have 8 ways to fill the tiles with the shape.
Once you finish those n games, you need to answer q queries.
Each query will give you one integer xj means the ways to fill the tiles.
You need to answer xj is in which round of the games?
If there're multiple answers, answer the earliest round.
If you can't find the answer, print "Go Down Chicken 404"
Sample input explain:
You have n = 5, q = 3
Then you have 5 integer: 6, 9, 13, 4, 3
If the tiles is 3*6: you have 8 ways to fill it.
If the tiles is 3*9: you have 0 ways to fill it.
If the tiles is 3*13: you have 0 ways to fill it.
If the tiles is 3*4: you have 4 ways to fill it.
If the tiles is 3*3: you have 0 ways to fill it.
Then you have 3 queries: 0, 4, 1024
There are multiple rounds turn out have 0 ways, but you need to answer the earliest round. The earliest round is second round.
Therefore the answer is 2.
The round that turns out have 4 ways is the forth round.
Therefore the answer is 4.
The round that turns out have 1024 ways can't be found.
Therefore the answer is "Go Down Chicken 404".

Input
The input is end with EOF
Each input contains several lines.
First line contains two integer n(1 <= n <= 1000000), q( 1 <= q <= 1000000).
Second line contain n integer ai( 1 <= ai <= 1000000).
Each ai is followed by a symbol "(/`A`)/ ~I__I" and separated by a blank from the next integer.
The following q lines each line contains one integer xj .
Output
For each query print that xj is the result of which round of the games(start from 1).
If there're multiple answers, answer the earliest round.
If you can't find the answer, print "Go Down Chicken 404"
Sample Input Download
Sample Output Download
Tags
Discuss
Description
"I have a dream that one day I can become a calculator."
~by anonymous Asian
But you are a programmer(you have no life). You can design a program to calculate for you(and become shame of Asian).
The input will contain multiple expression and end by EOF.
Each expression will only contain +, -, *, /, % and numbers(No parentheses).
You need to calculate the answer of the expression.
There may be several blanks or no blanks between operator and number.
You can use the code below and just finish the "Todo" part.
You can write your own code too.
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <ctype.h> #define MAX_LENGTH 1000 // Token / AST kinds enum { // Non-operators Value, // Operators /// Precedence 1 Mul, Div, Rem, /// Precedence 2 Add, Sub, }; typedef struct _TOKEN { int kind; int param; // Value struct _TOKEN *prev, *next; } Token; typedef struct _AST { int type; int val; // Value struct _AST *lhs, *rhs; } AST; // Utility Interface // Used to create a new Token. Token *new_token(int kind, int param); // Used to create a new AST node. AST *new_AST(Token *mid); // Convert Token linked list into array form. int list_to_arr(Token **head); // Use to check if the kind can be determined as a value section. int isValueSection(int kind); // Function called when an unexpected expression occurs. void err(); // Used to find a appropriate operator that split the expression half. int find_Tmid(Token *arr, int l, int r); //get the Precedence of operator or value int getOpLevel(int kind); // calculate the answer void getanswer(AST *ast); // Main Function char input[MAX_LENGTH]; int regis[1000], now_reg = -1; // Convert the inputted string into multiple tokens. Token *lexer(char *in); // Use tokens to build the binary expression tree. AST *parser(Token *arr, int l, int r); // calculate the answer void calculate(AST *ast); int main() { while(fgets(input, MAX_LENGTH, stdin) != NULL) { // build token list by lexer Token *content = lexer(input); // convert token list into array int length = list_to_arr(&content); // build abstract syntax tree by parser AST *ast_root = parser(content, 0, length-1); // calculate the answer calculate(ast_root); /*Todo*/ // print the answer here. /*Todo*/ // do some reset?? } return 0; } AST *parser(Token *arr, int l, int r) { if(l > r) return NULL; // covered in parentheses int mid = find_Tmid(arr, l, r); AST *newN = new_AST(arr + mid); if(l == r || newN->type == Value) return newN; /*Todo*/ //finish the parser return newN; } AST* new_AST(Token *mid) { AST *newN = (AST*)malloc(sizeof(AST)); newN->lhs = newN->rhs = NULL; newN->type = mid->kind; newN->val = mid->param; return newN; } int find_Tmid(Token *arr, int l, int r) { /*Todo*/ //find the node to be contructed } int getOpLevel(int kind) { /*Todo*/ // you may use this finction in find_Tmid } void calculate(AST *ast) { /*Todo*/ // traverse the tree by postorder } void getanswer(AST *ast){ /*Todo*/ // calculate the answer here. // you can calculate the answer by simulating the registers } Token *lexer(char *in) { Token *head = NULL; Token **now = &head, *prev = NULL; for(int i = 0; in[i]; i++) { if(in[i] == ' ' || in[i] == '\n') continue; else if(isdigit(in[i])) { int val = 0, oi = i; for(; isdigit(in[i]); i++) val = val * 10 + (in[i] - '0'); i--; // Detect illegal number inputs such as "01" if(oi != i && in[oi] == '0') err(); (*now) = new_token(Value, val); } else { switch(in[i]) { case '+': // '+' (*now) = new_token(Add, 0); break; case '-': (*now) = new_token(Sub, 0); break; case '*': (*now) = new_token(Mul, 0); break; case '/': (*now) = new_token(Div, 0); break; case '%': (*now) = new_token(Rem, 0); break; default: err(); } } (*now)->prev = prev; if(prev != NULL) prev->next = (*now); prev = (*now); now = &((*now)->next); } return head; } Token *new_token(int kind, int param) { Token *res = (Token*)malloc(sizeof(Token)); res->kind = kind; res->param = param; res->prev = res->next = NULL; return res; } int list_to_arr(Token **head) { int res = 0; Token *now = (*head), *t_head = NULL, *del; while(now!=NULL) { res++; now = now->next; } now = (*head); t_head = (Token*)malloc(sizeof(Token)*res); for(int i = 0; i < res; i++) { t_head[i] = (*now); del = now; now = now->next; free(del); } (*head) = t_head; return res; } int isValueSection(int kind) { if(kind == Value) return 1; return 0; } void err(){ exit(0); }

Input
The input will contain multiple expression and end by EOF.
Each expression will only contain +, -, *, /, % and numbers(No parentheses).
Each expression will not exceed 10000 characters.
We guarantee that every expression is legal.
Output
For each expression print the answer you calculate.
remember to print \n at every end of answer.