Translation Notice
This article was machine-translated using DeepSeek-R1.
- Original Version: Authored in Chinese by myself
- Accuracy Advisory: Potential discrepancies may exist between translations
- Precedence: The Chinese text shall prevail in case of ambiguity
- Feedback: Technical suggestions regarding translation quality are welcomed
A - Slots
Problem Statement
Given three uppercase English letters $C_1,C_2,C_3$, determine if they are all identical.
Input Format
$C_1C_2C_3$
Output Format
Print Won
if $C_1,C_2,C_3$ are equal; otherwise, print Lost
.
Sample
Input | Output |
---|---|
SSS | Won |
WVW | Lost |
Analysis
If you can’t solve this problem, you might as well have not learned C++
…
Code
Note: Do not write Won
as Yes
or Lost
as No
!
|
|
B - Alcoholic
Problem Statement
A person will drink $N$ cups of alcohol in order. The $i$-th cup has $V_i$ milliliters with $P_i\%$ alcohol content ($1\le i\le N$).
He gets drunk when the total alcohol consumed exceeds $X$ milliliters (consuming exactly $X$ milliliters won’t cause drunkenness).
After drinking which cup will he get drunk for the first time?
$1\le N\le 10^3$
$0\le X\le 10^6$
$1\le V_i\le 10^3$
$0\le P_i\le 100$
Input Format
$N~X$
$V_1~P_1$
$\vdots$
$V_N~P_N$
Output Format
Print the cup number $i$ if he gets drunk after drinking the $i$-th cup. If he never gets drunk, print -1
.
Sample
Sample Input1
|
|
Sample Output1
|
|
The first cup contains $200\times5\%=10$ ml of alcohol.
The second cup contains $350\times3\%=10.5$ ml of alcohol.
After drinking the second cup, the total $20.5$ ml exceeds $15$ ml, so output $2$.
Sample Input2
|
|
Sample Output2
|
|
He doesn’t get drunk when exactly $X$ ml is consumed.
Sample Input3
|
|
Sample Output3
|
|
Seems he’s immune to alcohol…
Analysis
The alcohol in the $i$-th cup is $V_i\times P_i\%$, i.e., $V_i\times P_i/100$ ml.
We need to find the smallest $i$ where the cumulative sum exceeds $X$ ml. However, due to floating-point precision issues in C++, direct calculation may yield incorrect results.
This allows integer arithmetic to avoid precision errors.
Code
|
|
C - Mandarin Orange
Problem Statement
There are $N$ bowls arranged in a row. The $i$-th bowl contains $A_i$ oranges.
Takahashi selects a triple $(l,r,x)$ satisfying:
- $1\le l\le r\le N$
- $x\le A_i$ for all $l\le i\le r$
He eats $x$ oranges from each bowl between $l$ and $r$ (inclusive). Find the maximum number of oranges he can eat.
$1\le N\le 10^4$
$1\le A_i\le 10^5$
Input Format
$N$
$A_1~\dots~A_N$
Output Format
Print the maximum number of oranges.
Sample
Sample Input1
|
|
Sample Output1
|
|
Choosing $(2,6,4)$ yields $5\times4=20$ oranges.
Sample Input2
|
|
Sample Output2
|
|
Choosing $(1,1,200)$ yields $200$ oranges.
Analysis
For each $(l,r)$, the optimal $x$ is the minimum $A_i$ in $[l,r]$. Compute $(r-l+1)\times\min(A_l,\dots,A_r)$ for all possible $(l,r)$ and find the maximum.
Time complexity: $\mathcal O(n^2)$
Code
|
|
D - Logical Expression
Problem Statement
Given $N$ strings $S_1,S_2,...,S_N$ (each being AND
or OR
), count the number of tuples $(x_0,x_1,...,x_N)$ satisfying:
- $x_i$ is $\text{True}$ or $\text{False}$
- $y_0=x_0$
- For $i\ge 1$: $y_i=y_{i-1}\land x_i$ if $S_i$ is
AND
, else $y_i=y_{i-1}\lor x_i$
$1\le N\le 60$
Input Format
$N$
$S_1$
$\vdots$
$S_N$
Output Format
Print the count.
Sample
See original contest page for details.
Analysis
$$f(N)=\begin{cases} f(N-1) & (S_N=\text{AND})\\ f(N-1)\times2^N & (S_N=\text{OR}) \end{cases}$$
This allows efficient computation while processing input.
Code
|
|