2124 - I2P(II)2020_Chen_week5_HW Scoreboard

Time

2020/10/13 00:00:00 2020/10/20 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12145 Species of Knuckles
12390 Construct tree by inorder and preorder

12145 - Species of Knuckles   

Description

There're different kinds of Knuckles in this world. According to the research, there're 26 different kinds of Knuckles.


Let's denote different kind of Knuckles as 'a' ~ 'z'.

Knuckles is a magic creature.

If you have at least 2 same kind of Knuckles, you can transform these Knuckles into any kind of Knuckles with same number of them.

For example:

if you have n=3 Knuckles representing as "aab" you can transform 'a' Knuckles into 'b' Knuckles. In the end you will get "bbb" Knuckles.

Because you're a deadly Ethnic nationalism, you want all Knuckles to be the same.

You can do the transformation many times.

Find out whether you can do that.

NOTE: Case 6 limits the memory to 1 MB, so try not to declare a large array.

Input

Input contains two lines.

First line contains only one integer n( 1 <= n <= 107 ), representing the number of Knuckles.

Second line contains one string, the length of n.

 

Output

If you can make all Knuckles the same, output "I'm the god of Knuckles!"

Otherwise,  output "Different makes perfect"

Remember to print \n at the end of output

Sample Input  Download

Sample Output  Download

Tags




Discuss




12390 - Construct tree by inorder and preorder   

Description

This problem is partial judge!

We will give you the "inorder" and "preorder" of a tree.

You need to construct a tree by the "inorder" and "preorder" we give you and print the "postorder".

There are three function you need to complete.

Node* buildTree(int *inorder, int *preorder, int *inorder_start, int inorder_end*);

function to construct the tree.

void showPostorder(Node *root)

function to print the postorder

void freeTree(Node *root)

function to free the tree

 

Notice that the the final testcase has small memory limit. If you don't free your tree you will get memory limit exceeded

 

 

 

 

 

 

(The tree for sample input 1)

(The tree for sample input 2)

Input

 

There are multiple testcases. The testcases will end with EOF.

Each testcase contains three lines.

First line only contains one integer n(1 <= n <= 100) which means the number of nodes in the tree.

Second line contains n integers which in the range of int. Standing for the "inorder".

Third line contains n integers which in the range of int. Standing for the "preorder".

It is guarnteed that no same number will appear in one tree.

 

Output

For each testcase output the "postorder" of the tree.

You have to output in this form:

testcase<id>: <postorder sequence>

Replace <id> and <postorder sequence> into the i-th testcase and the correct postorder sequence.

Each number in postorder sequence should be followed by a single blank(even the last number).

If you have further questions, please refer to sample output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12390.c

Partial Judge Header

12390.h

Tags




Discuss