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 - Full House
Problem Summary
Translation from a passionate card game enthusiast qwq
Given five card numbers $A,B,C,D,E$ from a poker deck, determine if they form a “three-of-a-kind plus a pair”. (Baidu it if unclear
Constraints: $1\le A,B,C,D,E\le 13$, and not all $A,B,C,D,E$ are identical.
Input Format
$A~B~C~D~E$
Output Format
Print Yes
if a full house, otherwise No
.
Sample Cases
$A$ | $B$ | $C$ | $D$ | $E$ | Output |
---|---|---|---|---|---|
$1$ | $2$ | $1$ | $2$ | $1$ | Yes |
$12$ | $12$ | $11$ | $1$ | $2$ | No |
Analysis
Hehe, amused by startled by my own translation—never seen such a good terrible one!
Straightforward problem. Count frequencies and check for exactly two and three counts. See code.
Code
|
|
B - Ancestor
Problem Summary
There are $N$ people. The parent of the $i$-th person is $P_i$, guaranteed $P_i < i$.
Find how many generations apart the $N$-th person is from the 1st person.
$2\le N\le 50$
$1\le P_i < i$
Input Format
$N$
$P_2~P_3~\dots~P_N$
Output Format
Print the answer.
Analysis
No DFS needed. Compute depth iteratively: $\text{depth}_i = \text{depth}_{P_i} + 1$.
Code
|
|
C - Monotonically Increasing
Problem Summary
Print all strictly increasing sequences of length $N$ with elements in $[1,M]$ in lex order. $1\le N\le M\le 10$.
Input Format
$N~M$
Output Format
Print each sequence in lex order, one per line, space-separated.
Analysis
Basic backtracking problem. See code.
Code
|
|
D - Left Right Operation
Problem Summary
Given integer sequence $A=(A_1,A_2,\dots,A_N)$, perform at most one left operation (replace first $x$ elements with $L$) and one right operation (replace last $y$ elements with $R$). Find the minimal possible sum.
$1\le N\le 2\times 10^5$
$-10^9\le L,R,A_i\le 10^9$
Input Format
$N~L~R$
$A_1~A_2~\dots~A_N$
Output Format
Print the minimal sum.
Analysis
Precompute prefix $f_i$ (min sum for first $i$ elements using left operations) and suffix $g_i$ (min sum for last $i$ elements using right operations). Answer is $\min(f_i + g_{N-i})$.
Time complexity: $\mathcal O(N)$.
Code
|
|
E - Sugoroku 3
Problem Summary
$N$ squares. On squares $1$ to $N-1$, a die outputs $0,1,\dots,A_i$ uniformly. Move forward by the die result. Find the expected steps to reach square $N$, modulo $998244353$.
$2\le N\le 2\times 10^5$
$1\le A_i\le N-i$ ($1\le i < N$)
Rational Number Modulo
For division, compute $A \times B^{MOD-2} \bmod MOD$.
Input Format
$N$
$A_1~A_2~\dots~A_{N-1}$
Output Format
Print the answer modulo $998244353$.
Analysis
$$ \text{dp}_i = \frac{\sum_{j=i}^{i+A_i} \text{dp}_j}{A_i+1} + 1 $$
Solve for $\text{dp}_i$ and use suffix sums for optimization. Time complexity: $\mathcal O(N \log P)$.
Code
|
|