Блог пользователя chokudai

Автор chokudai, история, 5 лет назад, По-английски

We will hold AtCoder Beginner Contest 192.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

  • Проголосовать: нравится
  • +109
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

11 minutes to go All The Best!!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

My screencast with commentary will be here once the contest is over.

»
5 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится +16 Проголосовать: не нравится

I'm planning to explain the solutions live on stream after the contest. I'm trying something new and doing it on Youtube — https://youtu.be/XTvl-idpAwc (you can watch the recording here too)

My screencast without commentary is at https://youtu.be/JeiFbb1RKjI (will publish at end of contest).

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +7 Проголосовать: не нравится

were most solutions failing in D due to overflow / precision issues ? I thought we can binary search but gave wrong answer in 13 cases even after handling the overflow. submission

UPD : it worked after handling the case where x has length 1 . I handled the case but incorrectly , probably overflow took away all the focus.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

It seems that E was easier than D.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how to solve E

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is D Binary Search or something else ?

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +10 Проголосовать: не нравится

Is D not a simple binsearch? I ended up changing to python to avoid overflow but still did not manage to solve it

Submission: https://atcoder.jp/contests/abc192/submissions/20328749

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится

Why nowadays Atcoder ask a lot of precision error or something similar

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Fixed the issue.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I would be really grateful if someone can look into my D submission why it is wrong ? I am doing binary search and dont really seem to have overflow issues My Code

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice Problems!

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

.

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +11 Проголосовать: не нравится

Nice contest.

I think the problems are really good and I enjoy it, what's more, the editorial is available once the contest is over.

If you got wrong answers in D and don't know what's wrong, the bugs might be:

  • The upper value of your binary search is too small.
  • You didn't specially deal with the case when X's length is 1.

I made the second mistake while solving the problem, so I got a lot of wrong attempt, what a pity! :(

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

For people facing problems with D, try the following : 1. Handle the case when string's length is 1. 2. During binary search, store the sum in double or long double, and whenever it exceeds M, break the summation loop. Long double is capable of storing large exponents. So it won't cause precision errors.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My solutions, along with explanations, can be found here :)

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +16 Проголосовать: не нравится

I solved D without binary search. More than that, I did not consider binary search at all!! What I did was separately handle cases where length of $$$X$$$ is $$$1, 2, 3$$$ and bruteforce+stopping early the other cases.

  • For case length of $$$X$$$ is $$$1$$$, print $$$1$$$ if value of $$$X$$$ is not greater than $$$M$$$, otherwise, print $$$0$$$.
  • For case length of $$$X$$$ is $$$2$$$, write the base-10 representation of $$$X$$$ as: $$$X_0 * b + X_1$$$ where $$$b$$$ is its base. I solve the equation $$$X_0 * b + X_1 \leq M$$$ to find upper bound of $$$b$$$.
  • Similar for case length of $$$X$$$ is $$$3$$$, I solve the equation $$$X_0*b^2 + X_1*b + X_2 \leq M$$$ using the quadratic formular.

Because the $$$b^3$$$ increases rather fast, $$$b$$$ only need to reach $$$10^6+1$$$ to surpass value $$$M\leq10^{18}$$$, so I don't need to manually handle further on.

I use Python to code, so It feels like I cheated because I don't have to worry about overflow.. Link to submission

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

would've been much more convenient if the editorial was one-paged instead of having to open different tabs

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can some one tell me why my sol is wrong for D? My solution I don't understand what I missed and it has been so much painful trying to find the mistake. T_T IGNORE I figured it out. It was an obvious dumb mistake :(

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why dijkstra's algorithm works for problem E? i solved it using dijkstra but i don't have a proof why it works.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +5 Проголосовать: не нравится

    The idea is that there is no point of arriving later than you can, because you can always wait at the destination, so it's better to find the shortest path. And I believe that with this fact you can just repeat a proof for dijkstra algorithm, maybe with some small fixes.

    You can also replace each vertex with infinitely many vertices, one for each moment of time. Then you have some directed edges between vertices, and also directed edges of weight 1 between copies of the same vertex. Then you can just run dijkstra on this graph, and it will work because this is just a directed graph (infinite graph, but whatever). I don't know your exact algorithm, but it should be easy to prove that what you do is more or less equal to running dijkstra on this graph, thus it is correct.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve F ?

  • »
    »
    5 лет назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Let the sum of elements you will mix be S.

    Brute force over the value of K from 1 to N (the number of elements you will mix), suppose you want to check K = 3, then you should take 3 elements from the array such that the sum of these elements is S and the following conditions holds:

    1. S%3 = X%3 (because this sum will be increased by K each second until reach X).

    2. Their sum S is maximum (because this will decrease the time we need to reach X).

    The last part (choosing K elements such that S%k = X%K and their sum S is maximum) can be done using dynamic programming, let dp[i][rem][mod] represents the maximum sum you can get when you are at index i and has to take rem elements and the sum of elements you taken so far modulus K equals mod, then you try to take or leave each element and return the optimal answer.

    Note that the value returned from dp will never exceed X, Because the max value you can get is 1e9 and X is at least 1e9.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Submission to D. Can someone help me with this submission? It fails only in one test case for problem D.