| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11419 | Using your vector (Implement a vector 3) |
|
| 11438 | Implement a list 2 (back) |
|
| 11443 | 3DShape |
|
| 11461 | Copy a vector (Implement a vector 7) |
|
| 11484 | Draw the Shapes |
|
| 11677 | Implement a list 4 (back and remove) |
|
| 12764 | Binary Search Tree for Shapes |
|
Description
Warning: You are not allowed to use:
1. any static variables
2. any variables which is not inside a function
3. malloc and free
由於實際的code有做其他檢查,因此為了讓各位方便閱讀,請參考簡化版本的function.h與main.cpp(請點連結)
This problem is similar to 11410 - Implement vector, but you have to do more things.
About how the instructions of vector work, please check above link.
This vector has an another operation, which is
- erase(): erases elements
You are required to do an employee statistic. Every employees has a name and an unique ID (starts from 0, increment after recruiting an employee).
You will have a class "God" which helps you construct class Employee and read the data members of Employee.
You have to implement
- Vector (push_back, erase, reserve, destructor)
- Employee(const std::string &name) (Don't forget to increase the ID_.)
- void add_employee(Vector &vec,const std::string &name)
- void print(const Vector &vec);
- void quit(Vector &vec,unsigned id)
- void quit(Vector &vec,const std::string &name)
You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")
Hint:
In C++, besides new expression, there is two operations simliar to new expression. One is called "operator new" (allocate memory) and the other is called "placement new" (construct object). You can think "new expression = operator new + placement new".
Here is some examples,
Input
Each input lines may be "recruit [name]", "quit 0 [name]", "quit 1 [id]", "reserve [size]", "capacity" or "size".
"recruit [name]" means push back the employee's [name] to the vector.
"quit 0 [name]" means erase employees from the vector if any employee's name is equal to the [name].
"quit 1 [id]" means erase employees from the vector if any employee's id is equal to the [id].
"reserve [size]" means reserve storage. (Increase the capacity of the container to a value that's greater or equal to new capacity. If new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.)
"capacity" means return the number of elements that can be held in currently allocated storage.
"size" means return the number of elements.
Output
Do the above operations. Print all elements in the vec after doing any operations. The print formate should be "employee_id employee_name\n".
Sample Input Download
Sample Output Download
Partial Judge Code
11419.cppPartial Judge Header
11419.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
You are required to implement a list.
Input
The input consist of a number of operations. Each operations (erase, insert and S) are separated by a newline character ('\n').
Operation push_back: following by a non-negative integer (insert value, 0<=insert value<65535). Push a node at the end position with insert value.
Operation pop_back: Pop a node at the end 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_back and pop_back) and operator<<(std::ostream &,const List &lst).
Sample Input Download
Sample Output Download
Partial Judge Code
11438.cppPartial Judge Header
11438.hTags
Discuss
Description
Warning: You are not allowed to use malloc and free
Giving a bass-class Shape3D and 4 derived class : Sphere (球體), Cone (圓錐), Cuboid (長方體), Cube (立方體)
You need to calculate the volume of each shape.
PS:
V of Sphere: V = 4/3 π r3
V of Cone: V = 1/3 π r2 h

note : Remember to do some basic check, if the input is illegal (e.g. length < 0, pi < 0 .....) then the volume should be 0.
You don't need to consider the scenario like Cuboid -1 -2 3, volume would be 0 instead of 6.
Hint1: Be careful the type of volume is double. 4/3=1 (int), so it should be 4.0/3.0
Hint2: You only need to implement the constructors.
Hint3: Note that Cube inherited Cuboid not Shape3D.
Input
There are only 4 shapes in this problem :
- Sphere, following by its radius and pi. (e.g. Sphere 30 3.14)
- Cone, following by its radius of bottom plane, height and pi. (e.g. Cone 3 100 3.14)
- Cuboid, following by its length, width and height. (e.g. Cuboid 2 3 7)
- Cube, following by its length. (e.g. Cube 2)
Output
Ouput the total volume of all the shapes.
Sample Input Download
Sample Output Download
Partial Judge Code
11443.cppPartial Judge Header
11443.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
Giving basic information of some shapes, you need to draw them on the Cartesian coordinate system and calculate the total area.
PI has already defined in function.h.
Input
There are only 2 shapes in this problem :
1. R (Rectangle), followed by 4 points. Each point represent 1 vertex of the rectangle, with the format (x, y).
2. C (Circle), followed by 1 point represent the centre of the circle, and a number of its radius.
If the radius is negative, set it to 0.
e.g., the result of sample input would be like :

Output
Output the total area of all the shapes.
Sample Input Download
Sample Output Download
Partial Judge Code
11484.cppPartial Judge Header
11484.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: 2048 byte
You are required to implement a list.
You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")
Input
The input consist of a number of operations. Each operations (push_back, remove and show) are separated by a newline character ('\n').
Operation push_back: following by a non-negative integer (insert value, 0<=insert value<20). Push a node at the end position with insert value.
Operation remove: following by a non-negative integer (remove value, 0<=insert value<20). Erase all nodes which data is equal to remove value.
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_back and remove) and operator<<(std::ostream &os,const List &lst).
Sample Input Download
Sample Output Download
Partial Judge Code
11677.cppPartial Judge Header
11677.hTags
Discuss
Description
Input
N
S_1 params_1
S_2 params_2
...
S_N params_N
1 <= N <= 1000
S_i can be either "Circle" or "Square"
params_i will be two numbers of double type if S_i is "Circle", otherwise one number of double type
Output
S_sorted_1(Area of the shape with least area)
S_sorted_2(Area of the shape with second least area)
...
S_sorted_N(Area of the shape with largest area)
The area should be printed with two digits after the decimal point.