atcoder_official's blog

By atcoder_official, history, 13 months ago, In English

We will hold AtCoder Beginner Contest 418.

We are looking forward to your participation!

  • Vote: I like it
  • +26
  • Vote: I do not like it

| Write comment?
»
13 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

I hope I can reach 800 in this contest.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

let's gooo

»
13 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Fun fact: 418 is a joke http status code, which indicates that this server is a teapot and cannot provide coffee.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Does anyone has any idea on how to solve C?Mine's Binary Search only got 5 out of 11.Waiting for solutions.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    obviously don't discuss in contest, but since contest is over now,

    • Sort the array, then make a prefix sum of it
    • For each query, find the maximum index suck that all the values are < x using the prefix sum. Let b be the number of elements less than x. Then, add (x-1)*b+1 to the previous value.
»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

E is a weaker version of LeetCode 3625 as the latter doesn't ensure every three points are not colinear.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +2 Vote: I do not like it

Problem E is similar to LeetCode 3625. Count Number of Trapezoids II, which appeared in the weekly contest three weeks ago.

»
13 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

The time limit is very bad in E.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    true i had to use unordered map

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    I used map during the contest and got AC *27,TLE *1.And I almost got mad during the contest.

    In addition,my method have to put a pair<long long,long long> and a pair<pair<long long,long long>,long long> in the unordered_map,but when I do this,I have to write the hash function by myself.It's so awful.

    The difficulty of E just worth these things above.So I dislike it very much.It makes me got -17 delta.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      I solve E with map. code

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        You're really lucky. Your maximum running time is 3990ms, which is only 10ms below the time limit.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it +1 Vote: I do not like it

      I meet same problem at first.

      So, I used discretization + binary search to reduce the constant factors and solve it.

      I learned a lesson: don’t assume you’re just doing an ABC contest and neglect the constant factors.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Yep, but I passed with map and fraction (a struct implemented by myself, used to do some calculations based on fractions).

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    The same

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve F?

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

So close yet so far on $$$E$$$ :(

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Challenging. :)

How F and G?

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +25 Vote: I do not like it

Problem G is very similar to https://qoj.ac/problem/12010. It does a great job of popularizing the Myhill–Nerode theorem. However, its downside is that it’s a bit too “brainless,” as contestants can simply copy a template they’ve written before to pass. I only spent ten minutes on it.

edit: Here is another blog about Myhill–Nerode theorem(in Chinese): https://oi-wiki.org/misc/fsm/#myhillnerode-%E5%AE%9A%E7%90%86

»
13 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

E is just Count Number of Trapezoids II, but with the tough edge cases omitted due to the easier constraints.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    My thoughts could not take me to final solution, All I observed is calculating slopes and count.

    For a given slope count ct we could make C(ct,2) lines. Then stuck at removing parallelograms.Could you guide what to do next?

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      There can be two approaches:

      • For a parallelogram, the mid-point of non adjacent vertices is the same, so for every pair you could store the midpoint in a map and the number of parallelograms is: (Here $$$x $$$ is the number of pairs with each midpoint) $$$ \sum{ x \choose 2}$$$.
      • We could also store the size $$$\left((x_1 - x_2)^2 + (y_1 - y_2)^2 \right)$$$, it is the property of a parallelogram to have opposite sides of same length, now for each slope, pair of segments with the same length will make a parallelogram (if they have different intercepts), so you can count them and then divide by $$$2$$$ (as we will overcount each parallelogram in the two slopes of its adjacent sides).
  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Hey uttaran can we just connect over linkedin ?https://www.linkedin.com/in/eshwarr/

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

when will the final ratings update

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

ahhhhhh only 1 min to submit my AC code of E!!!! my solution

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I am facing issue in understanding your code mainly in these steps

    sum*(sum-1) no /2 here

    we subtract (i.second)*(i.second-1)/2 (/2 here)

    at the end ans/2

    Could you explain how the extra counted parallelograms are getting subtracted.

    if we just do sum*(sum-1)/2 at each step we will have extra parallelograms that I understood.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it +1 Vote: I do not like it

      You can simply understand this as a whole concept. mp is about the mapping of edge directions, while mpp is the mapping of lengths for edges in the same direction. For each set of edges in every direction, it is always a trapezoid. And when calculating these quantities, parallelograms will be calculated twice. So let's think differently: calculate everything twice (sum*sum-1), and for all combinations of edges with equal lengths, they are only calculated once ((i.second)*(i.second-1)/2). They will definitely be calculated again in the other direction. So in the end, all combinations of four edges containing parallel edges will be calculated twice.

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        yeah I have understood that 4*p are included at first , then we are removing 2*p (here p represent count of parallelograms). Thanks

»
13 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

ABC are harder than CF div2 these days...

Screencast with commentary

»
13 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

lol :) lots of white iranian cheater guys ending in some suspicious numbers...

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Is there an original question for this competition?(这场比赛有原题吗)

»
13 months ago, hide # |
Rev. 4  
Vote: I like it +27 Vote: I do not like it

G trash casework solution: (Good means a string which can be reduced to "1")

0000: Only good is "1"

0001: Only good is all '1's

0010: Good if "1" or starts with 10 or (starts with "11" and has at least 3 1s)

0011: Good if starts with '1'

0100: Good if "1" or ends in "01" or (ends in "11" and has at least 3 1s)

0101: Good if ends in '1'

0110: Good if odd number of '1's

0111: Good if at least one '1'

1000: Bad if "0" or "01" or "10" or "11" or "000" or "101" or "111"

1001: Good if even number of '0's

1010: Bad if "0" or "01" or "11"

1011: Bad if "0" or "01111..."

1100: Bad if "0" or "10" or "11"

1101: Bad if "0" or "...111110"

1110: Bad if "0" or "11" or "101"

1111: Only bad is "0"

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Many of the operations there are associative, and for some of them, you can obtain any number that you want if they have a small enough number of terms, you really have to do pattern matching for the remaining ones, that is, 2, 4, 11, 13.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Enumerating all theses cases during contest. (orz)

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Did anyone faced similar situations in E?

I searched "trapezoid" in baidu, a Chinese search engine, and the first result was called "不规则四边形", which means "a flat shape with four straight sides, none of which are parallel", and I couldn't understand the example or its explanation, which also didn't explain what a trapezoid was...

I only understood it after seeing its further results called "a flat shape with four straight sides, one pair of opposite sides being parallel and the other pair not parallel". What's more, the online translation websites in China also gave me the first result I mentioned, so many other participants might be puzzled.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    This is the issue of Baidu and your English.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You must be knowing about 'trapezoid' from basic geometry class. If you forgot that and don't look at the wikipedia page, unfortunately, it's on you.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      bro, English is not my first language, so you really can't expect one to remember what a "trapezoid" is while learning "梯形" in Chinese.. I also mentioned above that

      Different cultures define a trapezium slightly differently and many have the term trapezoid too

      , so I wonder why no one else faced the same problem...

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        Actually, people faced the same problem. Even Um_nik mentioned it in his contest stream video.

        Apologies, I thought you have read geometry in English. This is why I always prefer to study CS or Math concepts in English. But I understand that it might create a confusion. In my country, the definition is what the question asked for.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think the E is easier than D.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    D was really guessable and E had an annoyingly tight time limit, so I'd personally disagree.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      how is it guessable ?

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it
        Spoiler
        • »
          »
          »
          »
          »
          13 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          ok next time will try to look for patterns by writing some test cases.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

In problem E I wanted to group edges by their slopes but I did not know how since slope take the form of x / y is there a trick for this ?

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Any clue why as to this submission to E gives TLE?

submission

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +1 Vote: I do not like it

    dont use map use unordered_map with a hash for pair<int,int> , the extra logn factor got by using map is causing this issue.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Who can help me solve Problem C?I got 6 WA.I think my logic is correct. First Try Second

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How long before the English Editorial?

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For question 2 considering the third given test case how can someone think they are only asking for character 't' and not for any other character?

»
13 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

How to solve problem F — We're teapots ?

What i understood till now :

  • number of ways to fill coffee and tea in n length array without constraints is
    ways[0] = 1;
    ways[1] = 2; 
    for(int i = 2; i <= n; i++){
        ways[i] = (ways[i-1] + ways[i-2]) % mod2;
    }
  • number of ways to fill exactly r coffee in n length such that any two cups has atleast one tea is (n-r+1) C r
  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    This is the toughest problem I have seen till date. Either the implementation of this is crazy tough or I am missing something.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

can anyone share the soln for E, like how to make sure that u dont take the same of set of 4 pts for a trapezium again, in case of a ||gm.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

This is a good solution to problem D by hitoare, can anyone explain it please :

source code
»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to do D?

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For the people asking for the solution of D:

The XNOR operation is associative, meaning the order of operations doesn't matter. For a string the final character is simply the XNOR sum of all its characters. If you notice carefully, the final sum for a string is '1' if the number of '0's is even, and '0' if the number of '0's is odd. The number of '1's doesn't affect the result.

Now, our task is to calculate the number of indexes $$$[l,r]$$$ such that count of '0's in substring $$$S_l$$$...$$$S_r$$$ is even. A substring from index $$$l$$$ to $$$r$$$ has an even number of '0's if the number of '0's in the prefix up to $$$r$$$ and the number of '0's in the prefix up to $$$l−1$$$ have the same parity.

For for each index $$$i$$$ we will check the parity of the count of '0's till now, and store that value. In the final answer we will choose how many ways we can pick $$$[l,r]$$$ from the odd and even parity respectively which is just $$$C(parityCount,2)$$$ and add them together.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Was anyone able to solve F without BST?

I can see the Japanese Tutorial mentions set or segment tree. But I don't think I completely understand the implementation given there.

»
13 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

Unfortunately, I spent too much time on problem E, since at first sight, I didn't pay too much attention to the condition that [No three points are co-linear].

However, fortunately, for problem F, I have met a similar idea (almost the same) just one week ago, which is Codeforces Round 612 (Div. 2) problem F. LCC.

The idea is that, we transform the dp equation into matrix-multiplication form, and for every query, we use segment tree to handle point-updating, so that the total complexity is O(2^3 n logn).

So, you could search how to solve Codeforces Round 612 (Div. 2) problem F, and after that, I think you can surely solve today's F as well.

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Bad time limit for E