1219 - CS I2P (II) 2017 Lee Quiz4 Scoreboard

Time

2017/05/26 13:20:00 2017/05/26 15:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11456 Implement a list 3 (front)
11460 string exam
11461 Copy a vector (Implement a vector 7)
11462 cppreference
11465 Use std::map
11466 vector and STL

11456 - Implement a list 3 (front)   

Description

You must follow the rules as below:

1. do not use any static variables

2. do not use any variables which is not inside a function

3. only new, operator new, delete and operator delete are allowed to allocate or deallocate memory

You are required to implement a list.

Input

The input consist of a number of operations. Each operations (push_front, pop_front and show) are separated by a newline character ('\n').

Operation push_front: following by a non-negative integer (insert value, 0<=insert value<65535). Push a node at the begin position with insert value.

Operation pop_front: Pop a node at the begin position.

Operation show: print the value of all nodes in the list. Print a whitespace character (' ') after printing the value of nodes. If the list is empty, do not print anything.

Output

Implement List (constructor, destructor, push_front and pop_front) and operator<<(std::ostream &,const List &).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11456.cpp

Partial Judge Header

11456.h

Tags




Discuss




11460 - string exam   

Description

Write a program that will reverse the order of words in each sequence of sentences while preserve the order of letters.

If the first character of word is vowel, add "ay" in the end position of the word.

Input

The input file will consist of several lines of several words. Words are contiguous stretches of printable characters delimited by a white space.

 

Output

The output will consist of the same lines and words as the input file. However, the order of words will be reversed.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11460.cpp

Partial Judge Header

11460.h

Tags




Discuss




11461 - Copy a vector (Implement a vector 7)   

Description

You must follow the rules as below:

1. do not use any static variables

2. do not use any variables which is not inside a function

3. only new, operator new, delete and operator delete are allowed to allocate or deallocate memory

4. memory usage limit: 16384 byte

You are required to implement a vector.

You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")

Input

There are seven functions in Vector that you have to implement, the functionality is as below:

  • default constructor: initializes pointers. Do not allocate memory.
  • copy constructor: copys the elements of rhs. The new capacity is rhs.size().
  • copy assignment operator: copys the elements of rhs. The new capacity is max(capacity(), rhs.size()).
  • erase: erases a element at pos.
  • insert: inserts a val at pos. When capacity is not enough, the new capacity is max(old capacity + 1, old capacity * 3).
  • reserve: reserves storage (Increase the capacity of the container to a value that's equal to new capacity. If new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.).
  • destructor

Output

Complete a Vector (default constructor, copy constructor, copy assignment operator, erase, insert, reserve and destructor).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11461.cpp

Partial Judge Header

11461.h

Tags




Discuss




11462 - cppreference   

Description

版本:

20180311

 

使用說明:

請下載code或header(兩個是同個檔案)

把附檔名從.cpp改成.zip

解壓縮後

reference>en>cpp.html

即可看到官方文件

Input

Output

Sample Input  Download

Sample Output  Download

Partial Judge Code

11462.cpp

Partial Judge Header

11462.h

Tags

CPP Reference



Discuss




11465 - Use std::map   

Description

This is an advanced version of http://acm.cs.nthu.edu.tw/problem/11447/

Notice, this time, first and last is [first, last].

Hint: std::map<std::string,...>

lower_bound and upper_bound can help you.

Input

The input consist of series of command. Each commands is insert, sum, range output, range erase or output.

insert: inserts a integer (0<=val<65536) with a string (key) to map. If the key has already existed, insert the val at the begining of integer (the val which the key belongs).

For example,

insert a 10

insert b 20

The map should contain 10, 20.

insert a 20

The map should contain 20 10, 20.

 

sum: sums up the integer with the key. Sum is 0 if a key is not existed. Output a newline character ('\n') after printing the sum.

For example,

insert a 10

insert b 20

The map should contain 10, 20.

insert a 20

The map should contain 20 10, 20.

sum a

It should output 30 (because 20 + 10).

 

range output: outputs the integer from key (first) to key (last). Output a space character (' ') after printing an element. Output a newline character ('\n') after printing all elements (even first key equals to last key).

For example,

insert a 10

insert b 20

The map should contain 10, 20.

insert a 20

The map should contain 20 10, 20.

range output a b

It should output 2010 20.

 

range erase: erase the integer from key (first) to key (last).

 

output: outputs all integer in map. From the smallest key to biggest key. Output a space character (' ') after printing an element. Output a newline character ('\n') after printing all elements (even map is empty).

For example,

insert a 10

insert b 20

The map should contain 10, 20.

insert a 20

The map should contain 20 10, 20.

output

It should output 2010 20.

Output

Complete the above operations.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11466 - vector and STL   

Description

這是一個幫助你了解vector與STL的問題

基本上,除了output與read_input以外的所有function,都可以只用STL完成,以下是function的介紹

  1. cat(lhs,rhs): 將lhs與rhs合併(lhs在前,rhs在後),並回傳合併後的結果
  2. erase_equivalent(vec): 移除vec裡面所有連續且重複的數字(相同的數字只保留1個),非連續但相同的數字不需要移除,並回傳移除後的結果 (e.g., 7 7 7 1 2 2 7 7 8 => 7 1 2 7 8)
  3. make_size_to(vec,new_size,num): 將vec的大小設定成new_size。如果new_size比原本的大小還大,則新的數字皆為num。如果new_size比原本的大小還小,則只保留前new_size個數字
  4. odd_num_count(vec): 回傳vec裡面,數字為奇數的數字的數量
  5. output(vec): 輸出vec裡面的內容,每個數字後面伴隨著一個空白,輸出完整個vec後再伴隨著一個換行
  6. read_input(vec): 利用cin讀入,並儲存到vec裡面。讀到0時表示輸入結束
  7. sort(vec): 對vec做排序,由大至小
  8. sort_abs(vec): 對vec做排序,開絕對值之後由小至大,若絕對值相等,則負數小於正數
  9. sum(vec): 回傳vec所有元素的加總,如果vec沒有元素,則回傳0
  10. mul(vec): 回傳vec所有元素的乘積,如果vec沒有元素,則回傳0

Input

根據cpp的main function描述,做出相對應的function

Output

根據上述function輸出

Sample Input  Download

Sample Output  Download

Partial Judge Code

11466.cpp

Partial Judge Header

11466.h

Tags




Discuss