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

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

We will hold AtCoder Beginner Contest 155.

We are looking forward to your participation!

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

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

I hope this one can be a little easier.

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

E is similar to this problem.

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

How to solve E and F ?

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

How to Solve D ?

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

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

Contest is over!

Difficulty on D was misplaced. Implementation wise, it was much harder than E.

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

This round really made me autistic(cross out) self-close

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

I guess this is one of the difficult ABC to me. (even though I got better rank than other contests just by solving A-B-C ).

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

Can anyone tell me the mistake I did in D, the first two samples are working and out of 72 TCs, almost half of them are working. I did a Binary Search from -10^18 to 10^18 and found out how many products will be less than the mid, and accordingly shift the high and low by comparing with k. https://atcoder.jp/contests/abc155/submissions/10161880 Also, do we require BigInt in E or is it doable without them? If yes, then can anyone tell me how?

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

    We can do E without using BigInt too.

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

    E doesn't need BigInt. In fact, I recommend you solve the problem by turning the String into an array of integers, then doing an O(N) sweep from right to left).

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

    I didn't find the bug but I have some suggestions.

    • You don't need long doubles. If a is a integer, a <= x is the same as a <= floor(x) and a >= x is the same as a >= ceil(x). You just have to be careful with negative values.
    • I found it easier to compute 2*(the number of pairs) and then divide it by 2 instead of just compute it directly.
    • I didn't understand why you count the number pairs with equal and smaller products in two different variables and use them differently. Shouldn't you always use their sum?

    I coded the same solution. https://atcoder.jp/contests/abc155/submissions/10145988

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

      Thank you for these suggestions, and for having a look at my code. I was coding it without using doubles but I was having a difficulty as some point so I thought it would be easier using doubles. I thought of calculating both values because I thought that if kth product was not unique then I might miss it because if I calculate all the products lesser than mid, it would be less than k and all the products less than and equal to mid would be greater than k. I couldn't come up with a justification why their sum would be used, can you help me with that too?

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

        Let f(x) = number of pairs with product <= x. The answer is the smallest X such that f(X) >= k.

        To have a intuition I think its enough to look at the first sample. $$$f(-13) = 0, f(-12) = 2$$$. So the answer for $$$k = 1$$$ is the same as $$$k = 2$$$ (-12).

        $$$f(-7) = 2, f(-6) = 4$$$, so the answer for $$$k = 3$$$ is the same as $$$k = 4$$$(-6).

        $$$f(7) = 4, f(8) = 5$$$, so the answer for $$$k = 5$$$ is 8.

        There is no need to compute < x and = x, just <= x.

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

      Hi Nson, could you please explain the div_floor and div_ceil functions as well as why do you need them?

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

        div_floor($$$a$$$, $$$b$$$) = $$$\lfloor \frac{a}{b} \rfloor$$$ and div_ceil($$$a$$$, $$$b$$$) = $$$\lceil \frac{a}{b} \rceil$$$.

        I wanted to count the number of elements $$$x$$$ such that $$$a_i * x \leq lim$$$, this is:

        • $$$x \leq \frac{lim}{a_i}$$$, if $$$a_i \gt 0$$$
        • $$$x \geq \frac{lim}{a_i}$$$, if $$$a_i \lt 0$$$

        And then I used floor and ceil to only work with integers.

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

        Also could you please explain where does the -1 come from in the following two lines:

        if(i < id) ans += id - 1;
        else ans += id;
        

        and

        if(i >= id) ans += n - id - 1;
        else ans += n - id;
        
        • »
          »
          »
          »
          »
          6 лет назад, скрыть # ^ |
           
          Проголосовать: нравится +1 Проголосовать: не нравится

          For $$$a_i \gt 0$$$ I want to count the number of $$$a_j$$$ such that $$$a_j \leq \frac{lim}{a_i}$$$.

          As the array $$$a$$$ is sorted, this is a prefix of it and with upper_bound I can find the size of this prefix. There is just one problem, if $$$i$$$ is in this prefix then I don't want to count the pair $$$(i, i)$$$ at the answer, but its enough to just remove 1 element(the $$$i$$$) from this prefix.

          For $$$a_i \lt 0$$$ it's basically the same thing, but the answer is a suffix of $$$a$$$.

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

Can E be solved using DP? If yes DP transitions, please :)

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

Can someone tell me the exact solution of D?

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

Why doesn't ABC get updated on Atcoder calendar anymore? I rely on the calendar for contest participations and I've missed like all the ABCs recently because of it.

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

How to solve F?

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

    Sort the A_i, so every operation concerns a subsegment of indices. Let D_i be the xor between B_i and B_{i-1}, where we consider that B_0 = 0. Our objective is to make D[] = 0. Notice that now every operation amounts to flipping the state of at most two elements of D.

    Build a graph on 1..n where indices i and j have an edge between them if an operation affects both. Notice that if we have a simple cycle x_1, x_2, ..., x_k then flipping the edge from x_1 to x_k has the same effect as flipping the other k-1 edges, so it's enough to take a spanning tree of each component. Now we can root each tree arbitrarily and greedily go from leaf to root, doing the correct operations to do everything except possibly the root equal to 0. If at the end the root is 0 we have to flip a single element in the tree in order to fix it. If no operation does that then it is impossible.

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

Was this streamed yesterday ? They are solutions to today's contest . It shows to be streamed on 15th Feb 2020 https://www.youtube.com/watch?v=SG60Cp9pSog is this Scam ?

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

Why cant they provide editorial in english when the majority is not from japan :/

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

https://atcoder.jp/contests/abc155/submissions/10169630

Can anybody explain what's wrong with this submission for problem E?

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

I'm much weaker than you all, could you tell me how to solve Problem C?

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

when will the English Solution be published?`\

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

https://atcoder.jp/contests/abc155/submissions/10152047

I appreciate if someone tells me what is wrong with this submission. It works fine with small tests, but gives wrong answer for the long one:

For the test 314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170 it returns 249 instead of 243.

the code is this:

int main()
{
    string s;
    cin >> s;
    
    int sum = 0;
    int last = 0;
    for(int i = s.length() - 1; i >= 0; i--) {
        int current = s[i] - '0';
        if(last)
            current++;

        if(current > 5) {
            current = 10 - current;
            last = 1;
        }
        else
            last = 0;

        sum += current;
    }
    sum += last;
 
    cout << sum << endl;
 
    return 0;
}
»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

please write the solutions in English too and provide setters/editorial writers code along with it. giving contests without having access to proper editorials is kinda frustrating.

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

    "For International Readers: English editorial will be published in a few days" They're doing a great work, give them some time. Also often you can understand the solution if you copy-paste the editorial into an automatic translator and read that.

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

Please Publish Editorials in english also ,so that non Japanese can understand....

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

English editorial is out!