# | Problem | Pass Rate (passed user / total user) |
---|---|---|
12534 | I'm reference |
|
13490 | K-unique |
|
14316 | Template Function |
|
14317 | Arena of Valor II |
|
14325 | I2P(II)2024_Kuo_Midterm2_rule |
|
Description
Download the C++ reference.
You will see the file named "12534.cpp" but that's OK.
Just download the file and change the filename extension(副檔名) into "zip" then you can upzip the file and use the reference.
The link is below.
Input
Output
Sample Input Download
Sample Output Download
Partial Judge Code
12534.cppPartial Judge Header
12534.hTags
Discuss
Description
There is a template function unique()
in STL (Standard Template Library), which takes two iterators \(begin, end\) as parameters, removes all except the first element from every consecutive group of equal elements in the left-closed-right-open range hold by the two iterators \([begin, end)\) and return the iterator to the new end, i.e., the next of the last element not removed.
For instance, in the first of the sample input, since \(k=1\), it's equivlent to the ordinary unique()
. So for the string "qqq", you should return the itrerator next to the first 'q'.
And in this problem, your task is to extend this feature more generally, i.e., remove all excpet the first \(k\) elements from every consecutive group.
Note
You should do it in place, returning valid iterator between origin range. Try to use constant extra space only.
If you want to run the code locally, you have to name your implementation Main.cpp. For more detail, please read instructions in the header.
Input
Since this problem is judged partially, you needn't be concerned about the format of input.
In case your're interested, there are several test cases, each of which contain four lines: the first line is two integers \(n, k\) and the following lines are a sring, \(n\) intergers and \(n\) floating point numbers.
\[0<n<10^6\]
\[0<k\leq n\]
Output
Since this problem is judged partially, you needn't be concerned about the format of output.
In case your're interested, for each test case, the judge code would print out the result after calling k_unique()
for the sting, integers and floating point numbers.
Sample Input Download
Sample Output Download
Partial Judge Code
13490.cppPartial Judge Header
13490.hTags
Discuss
Description
In this problem, you are required to implement four template functions: Reverse
, Minimum
, Maximum
, and Average
.
template <typename T> void Reverse(T *const base, size_t n);
function takes a pointer to the first element of an array and the size of the array. It reverses the array in place.template <typename T> T Minimum(T const *const base, size_t n);
function takes a pointer to the first element of an array and the size of the array. It returns the minimum element(with respect to the<
operator) in the array.template <typename T> T Maximum(T const *const base, size_t n);
function takes a pointer to the first element of an array and the size of the array. It returns the maximum element(with respect to the<
operator) in the array.template <typename T> T Average(T const *const base, size_t n);
function takes a pointer to the first element of an array and the size of the array. It returns the average of the elements in the array. IfT
is an integer/character/boolean type, round down the result. IfT
is a string type, return a string that contains one character, which is the sum of all the characters in all strings, divided by the sum of string length.
Note: You shouldn't modify the original array in the Minimum
, Maximum
, and Average
functions.
This line of code might come in handy...
template <>
std::string Average(std::string const *const base, size_t n)
Input
- This is a partial problem. Input and output are handled by
main
.
The first line contains an integer n
\((1 \le n \le 5 \times 10^4)\), the size of each array.
The second line contains n
integers, the elements of the array \(a\) (\(-10^9 \le a_i \le 10^9\)).
The third line contains n
integers, the elements of the array \(b\) (\(0 \le b_i \le 1\)).
The fourth line contains n
characters, the elements of the array \(c\) (\(c_i\) is a lowercase letter).
The fifth line contains n
strings, the elements of the array \(d\) (\(1 \le |d_i| \le 10^5\)).
\(n\)
\(a_1 \quad a_2 \quad \cdots \quad a_n\)
\(b_1 \quad b_2 \quad \cdots \quad b_n\)
\(c_1 \quad c_2 \quad \cdots \quad c_n\)
\(d_1 \quad d_2 \quad \cdots \quad d_n\)
Constraints
- \(1 \le n \le 5 \times 10^4\)
- \(-10^9 \le a_i \le 10^9\)
- \(0 \le b_i \le 1\)
- \(c_i\) is a lowercase letter
- \(1 \le |d_i| \le 10^5\)
- The sum of \(|d_i|\) is at most \(10^5\)
Output
- This is a partial problem. Input and output are handled by
main
.
Sample Input Download
Sample Output Download
Partial Judge Code
14316.cppPartial Judge Header
14316.hTags
Discuss
Description
Arena of Valor is a well-known action mobile game. The heroes in the game are divided into three classes: Archer, Mage, and Tank. Each class has its own advantages, making it a beloved fair competitive game for everyone.
Each hero can inflict damage on enemies through basic attacks and skills. The cooldown time for skills is 5 seconds, while basic attacks have no such limitation. Basically, the amount of damage to the enemy's health is determined by the hero's corresponding basic attack or skill attack power, but each class has some special effects:
- Archer: Basic attacks within 3 seconds after casting a skill gain bonus damage, decreasing in ratios of \(2\) times, \(\frac{5}{3}\) times, and \(\frac{4}{3}\) times respectively (rounded down).
- Mage: Skills only have a cooldown time of two seconds.
- Tank: Damage received is halved (rounded down).
Now, there are \(n\) heroes with \(q\) one-by-one matches. Each hero having their own health points (\(\text{hp}\)), basic attack power (\(\text{atk1}\)), and skill attack power (\(\text{atk2}\)).
You are currently acting as a battle recorder. You know what happens in the next \(q\) seconds.
As a battle recorder, you know which heroes are engaged in each battle. You need to record the outcome of each match, declaring the winner.
Please output the winner of each one-by-one match.
Shorter Description: Most of the topics are similar to Arena of Valor, the difference is that there are many one-by-one matches, and you need to output the winning hero.
Notes:
- When a hero's remaining HP is less than or equal to zero, they are dead, which means their apponent wins.
- When each battle ends, every hero can use their own cure power to reset their own hp and skill cooldown time.
- \(i\) battle with \(j\) means \(i\) attack \(j\) at the first second, \(j\) attack \(i\) at the second second, \(i\) attack \(j\) in the third second, and so on.
Input
The first line contains two integers \(n, q\).
Each of the next \(n\) lines contain one string and three integers \(\text{type}_i, \text{hp}_i, \text{atk1}_i, \text{atk2}_i\), represent the \(i\)-th hero.
Each of the next \(q\) lines have two integers \(i, j\), represent the \(i\)-th hero battles with the \(j\)-th hero.
\(n \quad q\)
\(\text{type}_0 \quad \text{hp}_0 \quad \text{atk1}_0 \quad \text{atk2}_0\)
\(\text{type}_1 \quad \text{hp}_1 \quad \text{atk1}_1 \quad \text{atk2}_1\)
\(\vdots\)
\(\text{type}_{n - 1} \quad \text{hp}_{n - 1} \quad \text{atk1}_{n - 1} \quad \text{atk2}_{n - 1}\)\(i_0 \quad j_0\)
\(i_1 \quad j_1\)
\(\vdots\)
\(i_{q - 1} \quad j_{q - 1}\)
Constraints
- \(1 \le n, q \le 10^4\)
- \(0 \le \text{hp}, \text{atk1}, \text{atk2} \le 10^9\)
- \(0 \le i, j < n\)
- type = "Archer" / "Mage" / "Tank"
- Testcase 1, 2 only contain "Archer" and "Mage"
- Testcase 3, 4 only contain "Mage" and "Tank"
- Testcase 5, 6 only contain "Archer" and "Tank"
- Testcase 7, 8 contain all types
Output
Please output the winner of each one-by-one match.
Sample Input Download
Sample Output Download
Partial Judge Code
14317.cppPartial Judge Header
14317.hTags
Discuss
Description
-
Only C and C++ are allowed. Solving problems with other languages (e.g. python, java) are forbidden, otherwise you'll get zero point.
-
STL and <algorithm> (except <string>) are forbidden.
-
-
Paper references, electronic devices, or other items that may contain any information relative to this exam are not allowed.
-
Before leaving, please tell TAs, we'll check if your accepted / partially accepted submissions are all written in C or C++. After you pass the check, you may return the account strip and leave.
-
The score of the exam will be total number of testcases you passed / number of testcases.
-
Recommended problem-solving order: 13629 -> 13631 -> 13630