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

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

We will hold Mirrativ Programming Contest 2025 (AtCoder Beginner Contest 414).

We are looking forward to your participation!

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

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

I hope this contest to be much better than last one :)

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

how to do C and D ??

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

    For C u can just brute force all decimal palindromes, for D u can observe that whenever u place a base station for a group of houses, its always optimal to place it in between so the strength for that station should be the distance between the farthest houses in the group, so u can just sort the distances between adjacent houses and remove the m — 1 biggest distances

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

    for problem D, in short, u need to view the question from a different angle. first sort the location of the houses, then you can think the problem like this: initially u have one station that cover from the first house to the last house, so power strength is (last-first)/2, then depends on the number of station you left to plant, u pick an index and divide the houses from that index, and make left side houses powered by a station while the right side powered by another station. you can do this division operation m-1 times, so be greedy as to where you divide.

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

      Still quite couldn't get the approach for D. Can you elaborate more..

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

        same couldn't get the solution . did you find a better solution? I was trying bs on answer i am not getting why it is not working

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

          " okay, the approach this not complicated, I'll show you an example take this as the input 7 2 5 10 15 20 8 14 15 so n = 7 and m = 2 now lets sort the array into 5 8 10 14 15 15 20 first try to use one station to cover every house, then the station is best to be placed at 12.5 so to minimize strength, which is 7.5 now the sum of strengths is simply 7.5, lets call it S(1) but we have two stations to plant, It means that I can split the array into two parts, and let each part be powered by a station. in that case we can split the houses in these 5 ways 5 10 14 15 15 20 -> sum of strengths (5-5)/2 + (20-10)/2 5 10 14 15 15 20 -> sum of strengths (10-5)/2 + (20-14)/2 5 10 14 15 15 20 -> sum of strengths (14-5)/2 + (20-15)/2 5 10 14 15 15 20 -> sum of strengths (15-5)/2 + (20-15)/2 5 10 14 15 15 20 -> sum of strengths (15-5)/2 + (20-20)/2 now, it is important to see, that in the first way, the total strength equals to S(1) - Gap, where Gap is the distance of the two houses where the split happen. e.g. in first way, the sum of strengths is (5-5)/2 + (20-10)/2 = 5, which is exactly S(1) - (10-5)/2 = 7.5 - 2.5 = 5 same goes for all of them so, the first and last way of split will give the minimum sum of strength, because they have the maximum distance between the two houses where the split happen so now the question translates to: you have m-1 operations to split the houses, and each time you split, the sum of strengths reduce by the distance of the two houses where the split happen. How to find the minimum sum of strength? "
        • »
          »
          »
          »
          »
          14 месяцев назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится

          Sort the houses and then think about it then the problem becomes, "There are n elements in an sorted array and we have to from k sub arrays such that the sum of (max-min) of each sub array is minimized."

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

    C is just bruteforce

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

For C, I tried to first generate all the base 10 palindrome in around O(sqrt(n)) time , i.e. for input n = 987654321, I enumerate from 1 to 98765 (the first half of n). then, I check if these number are also palindrome in base-A, but I keep getting TLE, and can't figure out a way to more efficiently generate palindromes

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

Why is the sample of problem F SO WEAK??????

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

Problem G is easy to think but difficult to write. :thinking:

It is different from other ABC.

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

https://atcoder.jp/contests/abc414/submissions/67547421 i am getting run time error in B on 2 test cases can someone tll thr error

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

for E, I arrived at this equation. How to compute this?

$$$ \sum_{b=2}^{n} \sum_{c=1}^{b-1} \left\lfloor \frac{n - c}{b} \right\rfloor $$$
»
14 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +2 Проголосовать: не нравится

Here's my feedback :

A : ok

B : why putting long long it's useless , but whatever it's just easy.

C : why it's harder than D ?? , also why you put tight limit , additional $$$\log$$$ factor is enough to TLE (and I'm surely not the only one who got this).

D : ok , but should have been swapped with C.

E : uh , ok but as soon as I read it , I knew it's floor sum trick with $$$+$$$ PIE.

(hire me for testing if you don't have good one ;) , will be great if I got paid lol)

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

Can d Be solved using binary search on answer ? I tried but was getting wrong answer ,anybody did with bs ?

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

    I tried to binary search on the answer, but than realize that it is not asking for the maximum strength among all stations planted, but instead the minimum sum of all stations strength. So, even though binary search will work in the first scenario it will not work as expected in the second.

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

    Minimize biggest range $$$\ne$$$ minimize total sum of ranges. It's possible that there exists a solution that has a bigger range but an overall smaller total. For example:

    4 2
    10 20 25 35
    

    In the example, its obviously possible to get a solution with $$$\text{max_sz} \le 10$$$ (cover first two with one, cover last two with another). But that's actually wrong! Notice that if the first station covers the first three houses and the last one covers the last house solo, that only incurs $$$15 + 1 = 16$$$ penalty instead of our $$$10 + 10 = 20$$$ penalty!

    Now, binary search can work, but it uses more complex ideas that you don't really need until you hit like, 2400 CF rating. This problem is actually way easier if you remove the binary search idea and instead ask this:

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

    You might be relating it with Angry Cows problem from USACO but I couldnt figure out a binary search solution for this since the power of each station is different, instead I came up with another very simple solution, sort the houses and then think about it then the problem becomes, "There are n elements in an sorted array and we have to from k sub arrays such that the sum of (max-min) of each sub array is minimized."

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

WTF is that PE, pure math!

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

E is a great problem.

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

How to do G? It kept TLE on 37 and other 3 testcases.

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

Trash contest.

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

Could anyone tell me why i got 3 TLEs in G? (https://atcoder.jp/contests/abc414/submissions/67547581) I'm crazy about it.

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

english editorial please!

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

The E problem is so nice that i only found out pretty easy after contest:(

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

Why is it downvoted ?

Thank you for editorial :) .

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

Can anyone give me the solution for F.

What i tried was find dis from root to every index using bfs then if dis%k == 0 then print dis/k or else -1. What am i missing here, why my solution won't work?

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

Reply to my previous comment about E link

I used Deepseek to understand and I'm writing it here so

  1. I can understand it more deeply

  2. others get helped

so we had $$$ \sum_{b=2}^{n} \sum_{c=1}^{b-1} \left\lfloor \frac{n - c}{b} \right\rfloor. $$$

Lets ignore the outer summation and focus on the one inside. Also let $$$ r = n\mod b $$$ so we get $$$ n = q.b + r $$$ where $$$ q = \left\lfloor\frac{n}{b}\right\rfloor $$$

so the inner equation becomes

$$$ \left\lfloor\frac{n - c}{b}\right\rfloor = \left\lfloor\frac{q.b + r - c}{b}\right\rfloor $$$

This can be rewritten as

$$$ \left\lfloor q + \frac{r - c}{b}\right\rfloor = q + \left\lfloor\frac{r - c}{b}\right\rfloor $$$

Notice that we have $$$ 0 \lt = r \lt b $$$ and $$$ 1 \lt = c \lt b $$$ so the $$$ r - c \subseteq [b - 2, 1 - b] $$$

Now the term $$$ r - c $$$ can be split into 2 cases, when $$$ r \gt = c $$$ and when $$$ r \lt c $$$. When $$$ r \gt = c $$$ we get $$$ 0 \lt = r - c \lt = b - 2 $$$ which when put into the floor always comes out to be 0.

When $$$ c \gt r $$$ we get $$$ r - c = -(c - r) $$$. You may notice that $$$ 0 \lt c - r \lt = b - 1$$$

$$$ 0 \lt \frac{c - r}{b} \lt = \frac{b - 1}{b} $$$

$$$0 \gt \frac{-(c - r)}{b} \gt = \frac{-(b - 1)}{b} $$$

This values is always of the form $$$ -1 \lt d \lt 0 $$$ whose floor always comes out to be -1. (Recall that floor is the largest integer <= x)

so now the inner summation breaks into the following

$$$ \sum_{c=1}^{b-1} \left\lfloor\frac{n - c}{b}\right\rfloor = \sum_{i=1}^{r} q + \sum_{i=r+1}^{b-1} (q - 1) $$$

which becomes $$$ rq + (b - 1 - r)(q - 1) $$$

Now we have to simplify this which follows:

$$$ rq + bq - b - q + 1 - rq + r $$$

$$$ bq - b - q + 1 + r $$$

Substituting $$$ r = n - bq $$$ as $$$ n = bq + r $$$

$$$ bq - b - q + 1 + n - bq $$$

$$$ n - b + 1 - q $$$

$$$ n - b + 1 - \left\lfloor\frac{n}{b}\right\rfloor $$$

so the final expression becomes

$$$ \sum_{b = 2}^{n} n - b + 1 - \left\lfloor\frac{n}{b}\right\rfloor $$$

which is equivalent to

$$$ \frac{n(n - 1)}{2} - \sum_{b=2}^{n}\left\lfloor\frac{n}{b}\right\rfloor $$$

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

.

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

I spent a lot of time on G,but spfa was hacked :(

https://atcoder.jp/contests/abc414/submissions/67562418

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

How can I contact the atcoder admins?
The questions didn't come up for me until 10 minutes after I started (I have to use a vpn)
I'm 100% sure I registered as a ranked player but nothing is added to me!
This is the first time I've managed to solve 5 questions in a contest and if I don't get ranked I'll definitely kill myself

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

Can anyone give me the solution for G?

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

Why does this Blog get downvoted so much? Personally, I think Atcoder provides quality problems. In addition, the staffs are really friendly too.