| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11417 | String Operation |
|
| 12753 | Go on mission |
|
| 13199 | Vector Implementation |
|
Description
Given a set of strings, perform the operations according to the following commands, and output the final result of the given set of strings.
Commands:
s n m: Swap the nth string and the mth string.
i n m: Insert the mth string at the tail of the nth string.
si n m: Swap the specified strings first, and then insert.
is n m: Insert first, and then swap the two specified strings.
e: Exit.
Consider a set of strings:
ab
cd
ef
And a sequence of commands:
s 0 1
i 1 2
The result will be:
cd
abef
ef
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
Input
The first line is an integer N indicating the number of input strings.
The following N lines each contains one input string.
Starting from the N+2th line will be a sequence of commands.
Output
Output the final result of the input strings.
Sample Input Download
Sample Output Download
Partial Judge Code
11417.cppPartial Judge Header
11417.hTags
Discuss
Description
This is a partial judge problem.

In Taisho-era Japan, demons hunt for human during night time. Therefore, Kisatsutai (鬼殺隊) sents demon slayers to protect the villagers. Tanjiro, Zenitsu, Inosuke are demon slayers who train themselves in Chouyashiki (蝶屋敷). Whenever there is a mission, Kisatsutai sents the one with highest health condition among the three. If their health condition are the same, the order of going on a mission is Inosuke > Tanjiro > Zenitsu. Initially, three of them have the same health condition. After they finish a mission, their health condition may compromise and need to rest and train themselves in Chouyashiki.
Their health condition is represented with a very big integer (<= 101200). Also, their health condition may be negative (but it is still okay to go on a mission).
Given the number of mission and how much health condition will be compromised in each mission, output each person's health condition after they finish all missions.
This is a partial judge problem. Inside function.h, there is a BigInt class for storing very big integer and a solution function to calculate the answer. Please choose C++11 compiler when submitting.
Explanation of Sample IO
Initially, three of them have equal health condition 71227122712271227122, and there are three missions.
For the first mission, Inosuke will go because he has highest order when they have same condition. After the mission, his health condition becomes 71227122712271227122 - 123456789987654321 = 71103665922283572801.
For the second mission, Tanjiro and Zenitsu have higher health condition. Tanjiro will go because he has high order than Zenitsu when they have same health condition. After the mission, his health condition becomes 71227122712271227122 - 91879487948794879487 = -20652365236523652365.
For the third mission, Zenitsu will go because he has the highest health condition. After the mission, his health condition becomes 71227122712271227122 - 7122712200000000 = 71220000000071227122.
Input
The first line is an integer N, begin the number of mission.
The second line is an integer H, begin the initial health condition of the three.
After that, there are N lines. The i-th line is an integer ci, meaning that the health condition of the one going on the i-th mission will be compromised by ci.
It is guaranteed that :
-
N <= 2000
-
0 <= H, ci <= 101200
-
-101200 < health condition < 101200, which means the health condition won't overflow the
BigIntclass.
Output
Please output three integers, each in a line.
The first integer is Tanjiro's health condition, the second integer is Zenitsu's, and the third is Inosuke's.
Note that there should not be trailing zeros or sign. For example, if the health condition is 87, you shouldn't print something like 00...0087; if the health is 0, you should print 0 instead of -0.
Sample Input Download
Sample Output Download
Partial Judge Code
12753.cppPartial Judge Header
12753.hTags
Discuss
Description
Vectors are sequence contianers representing arrays that can change in size. The example usage is as follow.
#include <vector> std::vector<int> v; for (int i = 0; i < 5; i++) v.push_back(i); for (int i = 1; i < 5; i++) v[i] += v[i - 1];
Vector is a commonly used STL, it's important to be familiar with the usage of vector. You're recommend to know what is a vector in advance. For more information of vector, you can google it or refer to the link.
In this problem, you are asked to implement a vector.
class Vector { private: value_type **arr_; size_type size_, cap_; public: ~Vector(); Vector(); Vector(const Vector &rhs); Vector &operator=(const Vector &rhs); reference front(); reference back(); reference operator[](size_type pos); const_reference operator[](size_type pos) const; size_type capacity() const; size_type size() const; void clear(); bool empty() const; void erase(size_type pos); void insert(size_type pos, size_type cnt, const_reference val); void pop_back(); void pop_front(); void push_back(const_reference val); void push_front(const_reference val); void reserve(size_type new_capacity); void shrink_to_fit(); };
The main idea that vector can change its size dynamically is because of the preallocation of extra memory spaces to accommodate for growth without the need to reallocate on each insertion.
value_type **arr_; size_type size_, cap_;
So size_ is the size of vector, and cap_ is the capacity of vector which is the size of the storage space currently allocated for the vector. arr_ is a double pointer, it points to the array that stores the pointer that points to the elements in the vector.
~Vector(); Vector(); Vector(const Vector &rhs); Vector &operator=(const Vector &rhs);
The constructor, destructor, copy constructor, assignment operator overload of vector.
reference front(); reference back();
Return the reference to front/back element of the vector.
reference operator[](size_type pos); const_reference operator[](size_type pos) const;
overload the [] operator to access the [pos] elements in vector.
size_type capacity() const; size_type size() const;
Return the size and capacity of the vector.
void clear(); bool empty() const;
clear() removes all elements from the vector and empty return true if the size of vector is 0.
void erase(size_type pos); void insert(size_type pos, size_type cnt, const_reference val);
erase(pos): remove the element at pos.
insert(pos, cnt, val): insert cnt elements which is val at pos. If the pos is equal to size of vector, it represents inserting the elemnt at the end of vector.
For example:
current vector is [7, 1, 2, 3] and insert(2, 3, 4) will cause the vector to becomes [7, 1, 2, 4, 4, 4, 3].
You can assume that the pos in the above two functions are all valid.
void pop_back(); void pop_front(); void push_back(const_reference val); void push_front(const_reference val);
Remove the last/first element from vector and insert val at the begin/end of the vector. You can assume that the program won't pop the element when the vector is empty.
void reserve(size_type new_capacity); void shrink_to_fit();
reserve(new_capacity): If new_capacity is greater than the current capacity, adjust the capacity to new_capacity.
shrink_to_fit(): Reduce the capacity to fits its size.
While inserting elements to the vector, if the capacity of vector is not enought, we often double the size of the capacity. It can let push_back becomes an O(1) amortized operation.
In order to verify the correctness of the implementation, main function will compare your vector with std::vector, if anything goes wrong, it should assert(false) and cause Runtime Error on online judge.
Note:
You're not allowed to modify the code other than the implementation of class Vector.
Please use new/delete, new[]/delete[] to dynamic allcoate the memory, and use at least C++11 to compile the code.
You're encouraged to trace the code to in-depth understand what you have to do.
Input
The random seed of main.cpp.
Output
Output the hash value and "AC" if the program excecutes successfully.