Thanks everybody for participating in the round!↵
↵
### [Div2A. Another Popcount Problem](https://codeforces.me/contest/2240/problem/A)↵
↵
Author: [user:wangmarui,2026-06-27] Preparation: [user:wangmarui,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Consider each binary bit independently.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Think about a greedy approach.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2240A]↵
</spoiler>↵
↵
### [Div2B. AI Finds Nothing Here](https://codeforces.me/contest/2240/problem/B)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Try some special cases, such as $r=c=2$, $n=r$, or $m=c$, etc.↵
</spoiler>↵
↵
↵
<spoiler summary="Solution">↵
[tutorial:2240B]↵
</spoiler>↵
↵
### [Div1A. Nim Game Is XOR Game](https://codeforces.me/contest/2239/problem/A)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Try working through some cases by hand. You may notice that whenever there is more than one non-zero number, the first player wins. Then think about why this is true.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239A]↵
</spoiler>↵
↵
### [Div1B. Decidophobia](https://codeforces.me/contest/2239/problem/B)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
How does everyone’s contribution change when you give a gift to someone?↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239B]↵
</spoiler>↵
↵
### [Div1C. Revival](https://codeforces.me/contest/2239/problem/C)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Consider determining all the numbers from back to front.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
When you determine a number, subtract $1$ from all previous values that are greater than this number. This way, all $p$ values decrease by one, while all $s$ values remain unchanged. Now you only need to solve the problem of determining the last number.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239C]↵
</spoiler>↵
↵
### [Div1D. Hunting the Beast](https://codeforces.me/contest/2239/problem/D)↵
↵
Author: [user:Milkcat2009,2026-06-27] Preparation: [user:Milkcat2009,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
By symmetry, all vertices are equivalent. Therefore, we only need to calculate the number of graphs in which a specific set is successful, and then multiply by $\binom{n}{m}$.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Let the nodes in the set be key nodes and the remaining nodes be non-key nodes. Consider the condition for the set to be successful and use the Principle of Inclusion-Exclusion to handle these conditions.↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
You might need to calculate the following: $n$ vertices form a set of disjoint cycles without self-loops. If there are $k$ cycles, the contribution is $(-1)^k$. Find the sum of contributions over all possible configurations.↵
↵
The answer is $1-n$, which you can try to prove.↵
</spoiler>↵
↵
<spoiler summary="Hint 4">↵
Use the Binomial Theorem to simplify the sum.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239D]↵
</spoiler>↵
↵
### [Div1E. The end of this world,](https://codeforces.me/contest/2239/problem/E)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
↵
<spoiler summary="Hint 1">↵
Notice that the problem can be transformed as follows: the $i$-th edge appears during the time interval $[\mathrm{low}_i, w_i]$. For each vertex, compute the maximum value of the departure time plus the weight of the destination vertex.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Consider doing the transitions from back to front.↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
We only need to support the following operations:↵
↵
- Add and delete edges;↵
- Query the maximum value in a connected component;↵
- Take the max of all weights in a connected component with a given number.↵
</spoiler>↵
↵
<spoiler summary="Hint 4">↵
Consider modifying the dynamic graph connectivity approach.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239E]↵
</spoiler>↵
↵
### [Div1F. Colorful Works](https://codeforces.me/contest/2239/problem/F)↵
↵
Author: [user:Milkcat2009,2026-06-27] Preparation: [user:Milkcat2009,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Consider the case where $l_i=0$.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Just Consider the most straightforward DP approach, and then try to find some patterns.↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
Try transforming the modulo $2$ counting DP into a game and solve it.↵
</spoiler>↵
↵
<spoiler summary="Hint 4">↵
You should already know the answer for $l_i=0$; try using the Principle of Inclusion-Exclusion to count.↵
</spoiler>↵
↵
<spoiler summary="Hint 5">↵
Enumerate which element is strictly greater than half of the total sum.↵
</spoiler>↵
↵
<spoiler summary="Hint 6">↵
You should already know the $O(nm/w)$ algorithm. Consider that, under modulo $2$, we have $(1+x^k)^2=1+x^{2k}$.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239F]↵
</spoiler>↵
↵
↵
### [Div2A. Another Popcount Problem](https://codeforces.me/contest/2240/problem/A)↵
↵
Author: [user:wangmarui,2026-06-27] Preparation: [user:wangmarui,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Consider each binary bit independently.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Think about a greedy approach.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2240A]↵
</spoiler>↵
↵
### [Div2B. AI Finds Nothing Here](https://codeforces.me/contest/2240/problem/B)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Try some special cases, such as $r=c=2$, $n=r$, or $m=c$, etc.↵
</spoiler>↵
↵
↵
<spoiler summary="Solution">↵
[tutorial:2240B]↵
</spoiler>↵
↵
### [Div1A. Nim Game Is XOR Game](https://codeforces.me/contest/2239/problem/A)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Try working through some cases by hand. You may notice that whenever there is more than one non-zero number, the first player wins. Then think about why this is true.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239A]↵
</spoiler>↵
↵
### [Div1B. Decidophobia](https://codeforces.me/contest/2239/problem/B)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
How does everyone’s contribution change when you give a gift to someone?↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239B]↵
</spoiler>↵
↵
### [Div1C. Revival](https://codeforces.me/contest/2239/problem/C)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Consider determining all the numbers from back to front.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
When you determine a number, subtract $1$ from all previous values that are greater than this number. This way, all $p$ values decrease by one, while all $s$ values remain unchanged. Now you only need to solve the problem of determining the last number.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239C]↵
</spoiler>↵
↵
### [Div1D. Hunting the Beast](https://codeforces.me/contest/2239/problem/D)↵
↵
Author: [user:Milkcat2009,2026-06-27] Preparation: [user:Milkcat2009,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
By symmetry, all vertices are equivalent. Therefore, we only need to calculate the number of graphs in which a specific set is successful, and then multiply by $\binom{n}{m}$.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Let the nodes in the set be key nodes and the remaining nodes be non-key nodes. Consider the condition for the set to be successful and use the Principle of Inclusion-Exclusion to handle these conditions.↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
You might need to calculate the following: $n$ vertices form a set of disjoint cycles without self-loops. If there are $k$ cycles, the contribution is $(-1)^k$. Find the sum of contributions over all possible configurations.↵
↵
The answer is $1-n$, which you can try to prove.↵
</spoiler>↵
↵
<spoiler summary="Hint 4">↵
Use the Binomial Theorem to simplify the sum.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239D]↵
</spoiler>↵
↵
### [Div1E. The end of this world,](https://codeforces.me/contest/2239/problem/E)↵
↵
Author: [user:Gold14526,2026-06-27] Preparation: [user:Gold14526,2026-06-27]↵
↵
↵
<spoiler summary="Hint 1">↵
Notice that the problem can be transformed as follows: the $i$-th edge appears during the time interval $[\mathrm{low}_i, w_i]$. For each vertex, compute the maximum value of the departure time plus the weight of the destination vertex.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Consider doing the transitions from back to front.↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
We only need to support the following operations:↵
↵
- Add and delete edges;↵
- Query the maximum value in a connected component;↵
- Take the max of all weights in a connected component with a given number.↵
</spoiler>↵
↵
<spoiler summary="Hint 4">↵
Consider modifying the dynamic graph connectivity approach.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239E]↵
</spoiler>↵
↵
### [Div1F. Colorful Works](https://codeforces.me/contest/2239/problem/F)↵
↵
Author: [user:Milkcat2009,2026-06-27] Preparation: [user:Milkcat2009,2026-06-27]↵
↵
<spoiler summary="Hint 1">↵
Consider the case where $l_i=0$.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Just Consider the most straightforward DP approach, and then try to find some patterns.↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
Try transforming the modulo $2$ counting DP into a game and solve it.↵
</spoiler>↵
↵
<spoiler summary="Hint 4">↵
You should already know the answer for $l_i=0$; try using the Principle of Inclusion-Exclusion to count.↵
</spoiler>↵
↵
<spoiler summary="Hint 5">↵
Enumerate which element is strictly greater than half of the total sum.↵
</spoiler>↵
↵
<spoiler summary="Hint 6">↵
You should already know the $O(nm/w)$ algorithm. Consider that, under modulo $2$, we have $(1+x^k)^2=1+x^{2k}$.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:2239F]↵
</spoiler>↵
↵



