| # | 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 |
|
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.cppPartial Judge Header
11456.hTags
Discuss
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.cppPartial Judge Header
11460.hTags
Discuss
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.cppPartial Judge Header
11461.hTags
Discuss
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).
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
Description
這是一個幫助你了解vector與STL的問題
基本上,除了output與read_input以外的所有function,都可以只用STL完成,以下是function的介紹
- cat(lhs,rhs): 將lhs與rhs合併(lhs在前,rhs在後),並回傳合併後的結果
- erase_equivalent(vec): 移除vec裡面所有連續且重複的數字(相同的數字只保留1個),非連續但相同的數字不需要移除,並回傳移除後的結果 (e.g., 7 7 7 1 2 2 7 7 8 => 7 1 2 7 8)
- make_size_to(vec,new_size,num): 將vec的大小設定成new_size。如果new_size比原本的大小還大,則新的數字皆為num。如果new_size比原本的大小還小,則只保留前new_size個數字
- odd_num_count(vec): 回傳vec裡面,數字為奇數的數字的數量
- output(vec): 輸出vec裡面的內容,每個數字後面伴隨著一個空白,輸出完整個vec後再伴隨著一個換行
- read_input(vec): 利用cin讀入,並儲存到vec裡面。讀到0時表示輸入結束
- sort(vec): 對vec做排序,由大至小
- sort_abs(vec): 對vec做排序,開絕對值之後由小至大,若絕對值相等,則負數小於正數
- sum(vec): 回傳vec所有元素的加總,如果vec沒有元素,則回傳0
- mul(vec): 回傳vec所有元素的乘積,如果vec沒有元素,則回傳0
Input
根據cpp的main function描述,做出相對應的function
Output
根據上述function輸出