atcoder_official's blog

By atcoder_official, history, 15 months ago, In English

We will hold AtCoder Beginner Contest 420.

We are looking forward to your participation!

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

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

it's on Sunday!

»
15 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Waited for a few minutes after 12:00 UTC for the tasks to appear, thinking the site hanged. Turns out its on sunday...

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

Some ABCs would be on Sundays later on. Interesting change, ruins my schedule :( but still gonna participate anyways

»
15 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

G too easy

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

Today's E is very easy.

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

G <<< F !!

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

Rubbish round.

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

May I kindly ask who invents the problem G and places it at G?????

Also I missed $$$n \cdot m \le 5 \cdot 10^6$$$ in F and obtain two TLEs because I wrote $$$O(\min^2(n,m)\max(n,m))$$$ with 100 percentage confidence.

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

    How you counted pairs ?? Or you didn't find any need to count them at all. Editorial uses Cartesian Tree but that is still unknown me to me.

    By Pairs I mean this :-

    // 1 <= X <= L. // 1 <= Y <= R. // 2 <= (X + Y) <= Sum.

    Maybe this part is the reason for my TLE. Can you please help ??

    My function looked like this :-

    i64 countPairs(int L, int R, i64 sum) {
    
        // 1 <= X <= L.
        // 1 <= Y <= R.
        // 2 <= (X + Y) <= Sum.
    
        if ((sum == 0) or (sum == 1))
            return 0LL;
    
        i64 a = min(1LL * L, sum - 1);
    
        if (a < 1)
            return 0LL;
    
        i64 b = max(0LL, min(a, sum - R));
        i64 c = b + 1;
    
        i64 ans = b * R;
    
        if (a >= c) {
    
            i64 count = a - c + 1;
            ans += count * sum - (a + c) * count / 2;
        }
    
        return ans;
    }
    
  • »
    »
    15 months ago, hide # ^ |
     
    Vote: I like it +11 Vote: I do not like it

    It's funnier because editorial solution for F uses cartesian tree (which isn't necessary) and that's still somehow meant to be easier than G

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

      G was an easy brute force Diophantine Equation. By the way how you approached problem F after utilising NSEE and PSE ??

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

    My solution is similar to yours. But I get an AC after 5 TLEs.

    code

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

where the solution gets uploaded?

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

image

After solving F, my rank only increased by ~100 cuz of G lol

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

bruh round

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

Lot of cheating in today round , don't what the point on cheating in the mock exams .

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

    Exams?

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

      Can you please help me like what I'm doing in the 4th problem I was using dynamic programming as the 500 I was just doing all the possible recursive calls but the issue was how I can keep the track of visited array because if I mark visited after going to the next Possible way I can also come to this path again , So is dp work in this problem or something else , i think about bfs but i didn't get approach using bfs , i have 50 minutes to think but i was not able to get victory over 4th problem again

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

        Recursion won't work. DP not required. You need to start BFS from the s node/cell.

        Treat this as a shortest path problem.

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

A true beginner contest after long time.

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

Swap D and G

»
15 months ago, hide # |
← Rev. 3  
Vote: I like it -23 Vote: I do not like it

Problem F is so shity. It involves too much discussion between different situations. It's really hard to implement all the details correctly in short time.

PS: It is able to pass using algorithms with complexity O(n*m*min(n,m)), which can be as much as 1e10 operations.

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

Well, D was a good exercise in basic BFS implementation, I guess. But the real "challenge" was figuring out why F was seemingly 10x harder than G (which had 10x the passes!). The difficulty allocation this time was truly baffling!

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

In problem G, 4x-1 = (2m+2n+1)(2m-2n-1). But how people who solved it, come up with this idea? Or there was another approach?

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

    Actually I upsolved it in a different way.

    if $$$\sqrt{n^2 + n + X}$$$ is an integer, then it must be a perfect square. So for some integer $$$k$$$,

    $$$ \begin{aligned} &n^2 + n + X = (n+k)^2\\ &\Rightarrow n^2 + n + X = n^2 + 2nk + k^2 \\ &\Rightarrow n = \frac{X - k^2}{2k-1} \end{aligned} $$$

    Then I just brute force every value of $$$k \in [-10^{8}, 10^{8}]$$$ and store every integer value of $$$n$$$ I encounter in this process.

    AC Link: https://atcoder.jp/contests/abc420/submissions/68790074

    • »
      »
      »
      15 months ago, hide # ^ |
      ← Rev. 3  
      Vote: I like it 0 Vote: I do not like it

      I used the same method, actually $$$k\in [-2\times 10^7,2\times 10^7]$$$ is fine, approximately, k is $$$sqrt(x)$$$

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

Super bad problem G, because G can be solved by chatGPT-5 in 2 minutes and 19 seconds. That's the reason so many people solved G.

Testers in ABC should enforce that at least problem F and G (or at least G) cannot be solved by GPT.

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

    It's nearly impossible. GPT-5 is really powerful yet. It can solve almost all the problems in previous ABCs.

    By the way, why your GPT needs 2 minutes to solve G? I suppose that GPT can solve this problem really fast, somehow in 10 seconds or less.

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

    AtCoder rules says "The use of generative AI is generally prohibited during ongoing ABC and ARC." So if someone uses GPT, that’s on them, that's against the rules.

    You said chat gpt needed 2 minutes 19 seconds for G, but that’s just skill issue. With my prompt it solves G in under a minute.

    If you want a non-GPT-able contest then make everything 2500-rated and watch only 100 people solve it. Otherwise stop spamming every contest blog. BEGINNER CONTESTS ARE FOREVER CHATGPT-ABLE. get used to it.

    stop the spam, thank you!

    [this is a reply to everyone complaining, not only to you.]

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

D — Toggle Maze.

Why BFS does work? See input below. Editorial Solution is 14 but correct is 16 : (4,2)->(3,2)->(2,2)->(3,2)->(4,2)->(5,2)->(6,2)->(6,3)->(6,4)->(6,5)->(5,5)->(5,6)->(4,6)->(3,6)->(3,5)->(3,4)->(4,4)

6 6
..o...
.?####
..#...
.S#G#o
??##?.
??x...
»
15 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

excuse me , who solve first problem in 16 freaking seconds

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

As my solution to F was different from editorial:

Assuming $$$N \leq M$$$, (if not, rotate), $$$N*M \leq 5e6 \implies N \leq sqrt(5e6) \lt 2237$$$

So we can bruteforce the upper row $$$r_1$$$ of the rectangle, and the rectangle height $$$h$$$ from $$$1$$$ to $$$\min(K,N-r_1)$$$ (0-indexed). As a result, we also have an upperbound of the maximum width $$$w = \lfloor \frac{K}{h} \rfloor$$$

For the current pair ($$$r_1$$$, $$$h$$$), call a column $$$c$$$ valid if all cells from $$$\text{grid}[r_1\ldots r_1+h-1][c]$$$ are free.

Now, it's a 1D problem. We have $$$M$$$ binary integers (valid column = $$$1$$$). To count all valid rectangles, we can group all contiguous $$$1\text{s}$$$ together. To solve naively in $$$\mathcal{O}(N^2*M)$$$:

For each group of $$$1\text{s}$$$, let the current group have length $$$X$$$

Case 1: $$$X \leq w$$$: Contributes $$$X*(X+1)/2$$$ to the answer

Case 2: $$$X \gt w$$$: Contributes $$$w*(w+1)/2 + (X-w)*w$$$ to the answer

This solution is too slow but we can speed it up.

Precompute for each cell $$$(i,j)$$$, the smallest $$$k$$$ such that $$$i \leq k$$$ and $$$\text{grid}[k][j]$$$ is obstacle (or $$$N$$$ if none exists).

Bruteforce from largest $$$h$$$ to lowest $$$h$$$, and add all columns that are valid for the first time at current $$$h$$$

When adding a column, use a DSU to maintain the current state of the group lengths and use three fenwicks to maintain the answer for each group length. The first fenwick for case 1, the other two to handle case 2. Make sure to start from $$$h = N-r_1$$$ but only add to answer for $$$h \leq k$$$

Final Complexity: $$$\mathcal{O}(N*(N+M)logM)$$$

Submission

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

    Thank you for sharing your solution, where the DSU part has really inspired me a lot. My solution is almost the same as yours, but instead of using segment tree, I use dp[x][y] to simplify the calculation.

    Here dp[x][y] means that for a grid consisting of only '.', with x rows and y columns, the number of valid sub-rectangles which start from the first row is dp[x][y]. For instance, dp[3][1] = 3, dp[2][2] = 6. This dp can be calculated based on the idea like two-dimension prefix sum.

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

It was a great contest, I enjoyed it.

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

If you solved https://cses.fi/problemset/task/1148 in a fast enough way, you can just paste, change some sizes, sum all rectangles $$$i\cdot j \lt = k$$$ and submit to problem F.