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

Автор atcoder_official, история, 13 месяцев назад, По-английски

We will hold AtCoder Beginner Contest 418.

We are looking forward to your participation!

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

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

I hope I can reach 800 in this contest.

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

let's gooo

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

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

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

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

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

    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 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

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

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

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

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

The time limit is very bad in E.

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

How to solve F?

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

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

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

Challenging. :)

How F and G?

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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

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

    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 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится +3 Проголосовать: не нравится

      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 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

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

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

when will the final ratings update

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

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

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

    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 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится +1 Проголосовать: не нравится

      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 месяцев назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

ABC are harder than CF div2 these days...

Screencast with commentary

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

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

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

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

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think the E is easier than D.

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

submission

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

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

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

How long before the English Editorial?

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

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 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

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

How to do D?

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Bad time limit for E