|
0
Hello sir. This is muy solution to 1702B. We can travel though the hole string, and use $$$ans$$$ to add up the sum of the days, and use $$$tot$$$ to add up how many letters Polycarp has remembered today. Another array $$$rem_x$$$ is used to mark if the letter is remebered. When $$$tot == 3$$$, this means he should use at least one more day, so we can When a new letter is remembered today, he don't have to remember it again, otherwise, Note that: please remember to clear $$$rem$$$ when '++ans'. My code: |
|
0
Yes, you are right, I made a lot of mistake on $$$int$$$ and $$$long \ long$$$. In a contest, you can try this: **** And when you use |
|
+1
In my opinion, after serveral operations, the number of the sum of $$$01$$$ and $$$10$$$ will not change. The problem says that $$$s_{i - 1} != s_{i + 1}$$$, for example, "100" will change to "110", and "001" will change to "011". We can find that the count of differences of the adjoining numbers will not change. In fact, XOR can find that if the adjoining numbers is not same, because $$$0 \ XOR\ 1 = 1$$$, $$$1 \ XOR \ 0 = 1$$$, $$$0 \ XOR \ 0 = 0$$$, $$$1 \ XOR \ 1 = 1$$$. I hope this solution can help you. |
|
0
I wonder that why I fail to hack to this code.
Can anyone tell me, thanks a lot. |
|
0
Note that, in problem G, don't use memset all the times, or you will get TLE on test 2 (I had tried it), because memset has a time complexity as $$$O(n \times \log a_i)$$$, if $$$t$$$ is very big, the total time complexity will be too large to solve this problem. I hope that this note will help you! |
|
0
Sorry, it's my mistake. Let me show you my code of problem E. |
|
0
Hello sir, There are two layers of recurrence in your code, so your code's time complexity is $$$O(n^2)$$$, and when $$$n = 200000$$$,you will get TLE. I solved this problem with set, and my time complexity is $$$o(n \log n)$$$. This is my code: Although there are two lawers of recurrence in my code, but $$$s[i].size \le 8$$$, so my code doesn't go TLE. |
|
-34
I think this contest is quiet interesting, but in my opinion, there are two drawbacks. First, it is easier than other div.2, like problem C and D, they are a little bit easy. Secound, why both problem C and D are all binary search. It's kind of repeated. |
|
+3
In my opinion, you can solve the problem in this way. Use an integer $$$a$$$ to save the minium number of operations to "cut" the trees in the same height . Consider that when you meet a "new" tree which has a height of $$$h$$$. There are two conditions.
We can find that in both situations, you have to operate $$$|h - a|$$$ times (This is the reason to add $$$|h - a|$$$ to the answer, $$$|h - a|$$$ is the $$$x$$$ in the official solution. In the end, you should add |a| operations to decrease / increase all the height to 0. This is my code:161360992 Thanks to user AAK who told me this method. I'm sorry that I am not good at using English to write articals. I hope this message will help you. |
|
+3
Thank you very much. Your solution is very helpful to me. |
|
0
Exuse me, may I ask a question? Does $$$curh$$$ mean the final leval that is equal all the height of the trees |