|
+1
In the testcase 2, when you try to link, but they are already in the same set (For example: 1, 4), you get a new chance to link another node.(we must satisfy first 4 condition, but may not to use all 4 chance to link.) So, when our code read (1, 4), we can link 1 and 5, get the set which has five elements. The answer for each i must be calculated independently., so we can sort it and greedily choosing the larger set. |
|
0
In problem F, I think solve two related problem which the number of changed digits in $$$[1, l]$$$ and $$$[1, r]$$$ is better. Than, we can use a simple subtraction to get the answer. If we focus on problem as $$$[1, x]$$$, we can find a way to calculate the ans: first, each digit can provide [ $$$11 \dots 11$$$ (the number of $$$1$$$ is $$$b$$$) $$$ * 10^b - 1$$$ ] changes ($$$b$$$ mean the current number of digits), than, we add $$$n - 1$$$ to the result, n is n-digits, finally, we get the correct answer. For example, to problem $$$[1, 5678]$$$, calculate detail is: $$$(5 * 1111 - 1) + (6 * 111 - 1) + (7 * 11 - 1) + (8 * 1 - 1) + (4 - 1)$$$. The logic of this way is the same as editorial. Here is my code, this may be clearer than my comment.My Code |
|
0
it is a blog use flows.CSDN But it is writing by Chinese.The key is using bipartite graph to build model, the left is days, the right is friends. I think you can read the code and know why it can be solved by flows. |
|
0
For Problem C, I try to maintain a struct as (value, las). The 'las' means the friend where it was last seen. And I think it can provides a ability to undo the previous operation (when it more than $$$\lceil \frac{m}{2} \rceil$$$). Through continuous withdrawal operations, I think if it has vaild case, it can be found. But I wrong answer on test 4. I can't find the hack data, here is my code: Code. My English is not good...very sorry... |