1297 - CS I2P (II) 2017-2 Lee Midterm Exercises Scoreboard

Time

2017/10/13 12:00:00 2018/01/15 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11371 Polynomial multiplication using linked list
11574 Prefix to truth table
11596 BSTR
11597 Copy a linked list (with friend)
11602 Editor

11371 - Polynomial multiplication using linked list   

Description

You are required to use linked list to do the multiplication of two polynomials.

Input

The input contains two lines. Each lines presents a polynomial. The format of each line is looked like : "5 4 -3 2 1 0" which means polynomial "5x4-3x2+1x0".

Each polynomial must contain a constant term. (You can use this rule to determine whether the polynomial is end.)

For example, "-2 3 1 1 0 0" should be -2x3+1x1.

(The input polynomial should be arrangement in descending power.)

Output

Output the answer. Print a space character in the begining.

For example, if the input is

5 4 -3 2 1 0 (means 5x4-3x2+1)

-2 3 1 1 0 0 (means -2x3+1x1)

the output should be 

" -10 7 11 5 -5 3 1 1" (which means -10x7+11x5-5x3+x).

If the value of coefficient is 0, you don't have to print it.

(The output polynomial should be arrangement in descending power.)

Sample Input  Download

Sample Output  Download

Partial Judge Code

11371.c

Partial Judge Header

11371.h

Tags




Discuss




11574 - Prefix to truth table   

Description

Give a prefix Boolean expression, which only has at most 26 variables ‘A’, ‘B’, ‘C’... 'Z', and 3 operators, AND ‘&’ , OR ‘|’, and ExclusiveOR '^', print its truth table which output equal to 1.

For example, if input is "4 7 &|AB|CA", then result will be

A B C D

0 1 1 0 
0 1 1 1 
1 0 0 0 
1 0 0 1 
1 0 1 0 
1 0 1 1 
1 1 0 0 
1 1 0 1 
1 1 1 0 
1 1 1 1 

Input

The input contains two unsigned short number (num and length) and a sequences of prefix expression.

  • First unsigned short number (num) means the number of variables from 'A' to 'A'+num-1. (e.g. 5 => 'A', 'B', 'C', 'D', 'E' )  1 <= num <= 26
  • Second unsigned short number (length) means the length of prefix expression.
  • A sequences of prefix expression only has at most 26 variables ‘A’, ‘B’, ‘C’... 'Z', and 3 operators, AND ‘&’ , OR ‘|’, and ExclusiveOR '^'.

Output

Print its truth table which output equal to 1. (It has ' ' behind each number)

Sample Input  Download

Sample Output  Download

Tags




Discuss




11596 - BSTR   

Description

Giving you a Binary Search Tree (BST) and a range, you need to remove all the nodes on the BST whose value is between the given range .

Input

The first line contains an integer N, represents the number of nodes in the BST.

The second line contains N integers, the first one is the value of root. For the remaining values, just insert them by BST's property.

The third lines contains 2 numbers, you need to remove all the nodes in the BST whose value is between these two numbers.

e.g. The BST constructed from sample input would be like : 

Output

Output the in-order traversal of the BST.

Note: The corret result should be in ascending order .

Sample Input  Download

Sample Output  Download

Partial Judge Code

11596.c

Partial Judge Header

11596.h

Tags




Discuss




11597 - Copy a linked list (with friend)   

Description

Every node has

  • id
  • friend (a node inside the same linked list. The value may be NULL.)
  • next (to next node)

You are required to copy a linked list with same structure.

Input

The first line contains a non-negative integer N (1<=N<=100000). N represents how many node inside a linked list.

main function will create a linked list for you.

What you need to do is implement copy function in function.h.

Output

Copy the linked list.

Your copied linked list must have same structure as input.

 

Case 2 is designed for those who wants a challenge:

You will get Memory Limit Exceeded if using too much memory.

You will get Time Limit Exceeded if spending too much time iterating nodes from head.

You can pass the case 2 if you use another memory (e.g., Node *temp[100000];). However, this is not the correct answer.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11597.c

Partial Judge Header

11597.h

Tags




Discuss




11602 - Editor   

Description

請使用linked list寫出一個簡單的Editor,並且有上下左右、backspace、newline、erase功能

Input

input只有一行且最後沒有換行符號('\n'),裡面會有char a~z, A~Z, 0~9, 空白(' '), 逗點(','), 句點('.'), 驚嘆號('!'), 問號('?'), 左括號('('), 右括號(')'),當輸入這些字元,則在游標所在位置新增這個字元,注意:游標一開始就會在第一行的開頭

以及特殊指令

  • 上 (/u): 將游標往上一行移動,並將游標移動到與原本那一行所在的位置相同(如果移動後的這一行字元數不足,則將游標移動到最後面),若沒有上一行,則不做動作
  • 下 (/d):將游標往下一行移動,並將游標移動到與原本那一行所在的位置相同(如果移動後的這一行字元數不足,則將游標移動到最後面),若沒有下一行,則不做動作
  • 左 (/l):將游標向左移動一格,若已經移動到開頭,則不做動作 (注意: 若這行是 abc,游標是可以移動到a前面,輸入1可以得到這行為1abc)
  • 右 (/r):將游標向右移動一格,若已經移動到結尾,則不做動作
  • backspace (/b):刪除游標前的一個字元
  • newline (/n):換行,將游標移動到新的這一行
  • erase (/e):刪除一整行(包括這一行內的字元及這一行空行),並將游標移動到下一行的最後面(若要刪除的這一行為最後一行,則將游標移動到上一行的最後面),若全文只剩下自己這行,則只需將這一行的字元刪除即可

注意: 左移右移、backspace只會在這一行移動游標,而不會使游標移動到其他行

Output

根據input,輸出全文(每一行最後都須有換行符號'\n')

Sample Input  Download

Sample Output  Download

Tags




Discuss