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

Автор emorgan, 4 года назад, перевод, По-русски

Всем привет!

В это воскресенье, 20-го марта 2022 года в 11:00 по московскому времени начнется Финал Технокубка 2022!

Итоговые результаты финального раунда Технокубка >>>

Для тех, кто хочет посоревноваться на тех же задачах, будет проведен обычный раунд Codeforces, совмещенный для всех дивизионов. Раунды начнутся в 20.03.2022 14:35 (Московское время), не пропустите!

Конечно, если вы участвуете в финальном раунде Технокубка, то вы не можете участвовать в раунде 778. Мы просим участников официального финала воздержаться от обсуждения задач в открытых сообществах до конца раунда.

Этот раунд подготовлен при участии следующих людей:

Разбалловка (для раунда 778): $$$500 - 750 - 1250 - 1750 - 2250 - 2500 - 3500 - 4000$$$.

Editorial

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

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

I hope I can get to blue, although that's impossible for me.

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

Please no boring&standart segment tree problems, dont repeat mistakes of the previous 2 years... Please...

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

Clashing with ABC 244 :(

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

I will lose blue in this round

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

as a tester, the problems are pretty neato burrito!!

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

Is this the remorphed version of "Go Study Round 1"?

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

    This is the problem set that was originally intended for Go Study Round 1. It's possible that the Go Study round could still happen in the future with a different problemset, but I don't know anything about it.

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

Both the UTC and Moscow time are incorrect. Please rectify.

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

As a tester, I don't remember having so many positive feelings about a problemset. I had a lot of fun testing, and I am sure you'll enjoy the contest, too!

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

If there is no particular reason for the unusual time then I would like to request to authors and coordinators of this round to please shift it to the usual time so it doesn't clash with AtCoder Beginner Contest 244 and we can have a nice 35 minutes break.

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

Expected to get cyan after this round.

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

Unusual time again :(

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

Why 8 problems in 2:15 and not in 3 hours?

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

hello sir, may i knwo how to be a tester, for the april fools round 2022 ?

Thnks

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

I am looking forward to this round, but emorgan, did you write 2022 as 2021 in the first sentence?

upd : I'm glad to see that this problem has been fixed.

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

I was really looking forward to giving both Atcoder ABC and this round but looks like I am gonna have to choose.

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

Orz USA Round!

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

:)

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

Can someone please explain what does it mean by Div 1 + Div 2 ?? Is it a combination of two rounds?

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

    It means it will be rated for both div1 and div2 and questions could be expected to have difficulty accordingly. Like generally, these 2 are held separately. To get a better idea go through other div1+div2 rounds' questions. All the best btw.. :)

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

It clashes with AtCoder Beginner Contest 244 :(

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

I hope I will become CM tonight

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

firs time on rated. lets go green :'v

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

Good luck to everybody and myself. hoping to get green :)

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

Score(A+B) == Score(C)

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

Round will it not be rated?

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

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

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

Bye ! expert

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

How to do C?

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

Can someone explain why does this code gives wrong answer on Problem D 150270389

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

Is F 2^27?

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

    It should be $$$O(n2^n)$$$, but I'm still debugging my code due to some annoying border cases.

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

    It can be solved with classic suffix array construction. If you sort prefixes of length $$$2^k$$$ for every $$$j$$$, then

    $$$s_j s_{j \oplus 1} \dots s_{j \oplus 2^{k+1}-1} = (s_j s_{j \oplus 1} \dots s_{j \oplus 2^k-1})(s_{(j \oplus 2^k)} s_{(j \oplus 2^k)\oplus 1} \dots s_{(j \oplus 2^k) \oplus 2^k-1})$$$

    Thus, you can compare prefixes of length $$$2^{k+1}$$$ by comparing pairs of prefixes of length $$$2^k$$$.

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

How to solve E?

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

    I want to know this too

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

    My approach is as follow:

    Let $$$b_i=a_{i+1}-a_{i}$$$ for $$$1\le i \lt n$$$

    If final $$$|b_i| \gt \sqrt n$$$,there will be less than $$$\sqrt n$$$ elements not being operated. Calculate for every $$$i$$$ with brute force is okay.

    Otherwise we have $$$|b_i|\le \sqrt n$$$ we can calculate the most remaining element for every $$$b\in[-\sqrt n,\sqrt n]$$$. We can classify every $$$a_i$$$ with $$$a_i-(i-1)b$$$.

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

    Either $$$|\text{difference of AP}| \lt \sqrt{a_{max}}$$$ or $$$len(AP) \lt \sqrt{a_{max}}$$$.

    We can check for all possible differences in the first case in $$$O(n \sqrt {n})$$$

    In the second case realize that for a difference $$$d$$$, the difference between two terms at positions $$$i \lt j$$$ must be $$$(j - i) \cdot d$$$. Since $$$|d| \gt \sqrt{a_{max}}$$$, this will exceed $$$a_max$$$ in at most $$$\sqrt{a_{max}}$$$ steps.

    Unfortunately I didn't realize that the initial statement directly gives you the way to solve the second part during contest T_T.

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

    You need to find maximum sub-sequence $$$i_1, \dots, i_m$$$ such that for each $$$k$$$ in the sub-sequence

    $$$a_k = b \cdot k + c,$$$

    where $$$b$$$ and $$$c$$$ are some constants. If $$$i$$$ and $$$j$$$ both belong to the sub-sequence, then

    $$$b = \frac{a_i - a_j}{i - j}.$$$

    But $$$|a_i - a_j| \leq 10^5$$$, so either $$$|b|$$$ or $$$|i-j|$$$ is less than $$$\sqrt{10^5}$$$.

    So, you check all $$$b$$$ that are smaller than $$$\sqrt{10^5}$$$ and also all sub-sequences that their width is at most $$$\sqrt{10^5}$$$.

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

why the memory limit of D is 256MB. My program can't pass only because of this limit. I think this problem would be better if it's memory limit is 1GB

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

Great problemset, thanks to authors!

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

How difficult...TAT

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

What is the reason for higher time constraints on the problem 1654B - Prefix Removals?

This N^2 150248852 submission passes because of that.

And I also have a failed hacking attempt on it :-/

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

    This is actually $$$O(26 * n)$$$ — it traverses the string only once for each letter of the alphabet

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

      Yes, I understand that but the string is passed by value which is O(N), and also the erase function should give O(N) complexity for every operation.

      Also, you can see that the code takes 1000+ ms for execution, which an N*26 solution won't give.

      The time constraints should be accordingly so these types of solutions don't pass.

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

        Yeah, I guess the compiler optimizes it and the time limit allows it to pass the pretests Not sure whether it will pass systest though

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

          It will pass. Two seconds of time allocation for this question is really too much.

          I don't know about compiler optimization, but strings take lesser memory than integer arrays of the same size, so maybe lesser complexity for operations.

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
Here's the solution for C if you're curious that's the simplest way i think
  • »
    »
    4 года назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится
    One can also implement it like this. I think this way is easier.
  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Surprised to see multisets works. I thought we must use maps.

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

If s is a multiset, is if(s.count(x)) $$$O(\log n)$$$ or $$$O(c\log{n})$$$ ($$$c$$$ is count of $$$x$$$ in s)?

I used to think it's $$$O(\log n)$$$ cause the compiler will optimize it. Until today I found this will keep fucking TLE unless I change it to s.find(x) != s.end() or add Ofast optimization manually.

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

For C this was my approach. Can someone explain why this is wrong.

example: 7 1 1 1 3 1 3 3 2 3. Sort the array in descending. 7 3 3 3 3 2 1 1 1 1.

Divide the array in equal sum halves. Meaning this array will be divided into 7 3 3 (sum1 = 13) and 3 3 2 1 1 1 1 (sum2= 12). If abs(sum1 — sum2) <= 1. I will recursively apply this on half1 and half2 until either only one element is left (which return true) or this (abs(sum1 — sum2) <= 1) condition is not met in which case false is returned. if both halves return true then only the answer is yes otherwise no.

My submission: https://mirror.codeforces.com/contest/1654/submission/150266681

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

https://mirror.codeforces.com/contest/1654/submission/150251750

can anyone please tell why this code is getting TLE on test#7, it seems correct to me

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

Can anyone tell me why this code is getting TLE(on pretest 9) for problem 1654C - Alice and the Cake, I think My code complexity is O(logn*log(sum)) My code

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

Why not test problem A first?

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

The questions are nice, but time limits/constraints are not (For problem E).

My solution for problem E runs in $$$O(n\sqrt n)$$$ and I believe it is already the optimal time complexity (correct me if I'm wrong). However, I still had to do like 40 minutes of constant optimisation and get a few penalties for the TLE verdicts.

I have also seen that many other submissions are only just under the time limit, in fact, 1/3 of solutions that passed pretests used more than 4s. There are also around 2.3 times more TLE submissions than AC submissions to add to the fact.

This also caused bottlenecks for other languages, with only 4 languages (C++, D, Java, Rust) having AC solutions on this task.

I believe these kinds of constant optimisation are absolutely unnecessary to competitive programming and does not bring anything extra except benefitting those with templates optimised for constant optimisation, which is irrelevant to one's actual algorithmic skills which competitive programming is supposed to test.

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

    For me, $$$O(n \sqrt n)$$$ with unordered_map got TL, but just sorting and solving in $$$O(n \sqrt n \log n)$$$ somehow passes...

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

    well.. I just failed system tests.. I should have done more constant optimization xD

    upd: my solution got rejudged and got accepted. Is that a new feature?

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

    Dear contestant,

    Please don't worry if you had to make some formulas shorter in order to pass a time limit that was set as a triple of our solution's running time. In a programming competition, the way you express your ideas in code actually matters. Apologies if this does not fit your view.

    Thanks for the feedback,

    A mere alt account.

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

    I agree with your perspective that requiring constant factor optimization does not make the contest any more interesting. We did not want any solution with correct complexity to get TLE (at least I didn't, I cannot speak for the other preparers). In this case, we made the constraints of E more lenient several times during testing, until the official solution (which uses hashmaps) ran in 1700ms -- at that point we thought the time constraints were reasonable.

    In the majority of cases where contestants complain about problems requiring constant factor optimization, it's not because the authors intentionally wanted to require it, but rather because there was a known brute force solution that could easily pass if the constraints were more lenient, or because changing the constraints would give away the intended complexity, or because increasing the TL would lead to queuing during the round.

    In this case, in hindsight, I would say we perhaps should have lowered the constraint on $$$n$$$, but I'm not 100% sure about it. Such a change would have likely allowed a few highly optimized $$$O(n^2)$$$ solutions to pass, and it's not clear whether that's a "lesser evil" than causing some solutions with poor constant factor to get TLE.

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

My approach for C:

-> The sum of array is the starting weight.

-> We can store the count of array elements in a map.

-> We start the simulation using a priority queue, with starting weight inserted in PQ:

->We take the top most element from PQ and check if it exist in the map:(2 possibilities)

  • If it does not exist, it means probably it was divided into 2 pieces later, so we will divide this piece into 2 parts and push them into PQ, to get divided later.

  • If it exists, it means this will be part of the final array, so we will consider that this particular element has been obtained correctly and thus won't be divided further, and we will update the count of this element in map by decreasing by 1;

-> We do this simulation n-1 times.

-> Now, in the ideal case, all the keys in map should have a value 0 as its count.

-> if above statement is true -> return YES; else return NO;

P.S.: Queue would also work fine in this case, as processing the elements in any order will give the same end result. 150248249

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

How to solve problem D? I have a basic idea but couldn't figure out how to deal with node with n-1 degrees. It would easily overflow.

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

I fell shocked when refreshing the status page and found lots of my friends fst on problem E

panic

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

Me after submitting D in the last 5 seconds with a correct solution but then realized I'm printing the value at the root and not the sum.

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

It's a pity that I've only got 15 minutes to participate in the contest :( Luckily, I solved 2 problems within 12 minutes, so this contest is almost unrated for me XD

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

problems A and B were actually pretty easy but then C was very hard compared to A and B

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

I got TLE on problem E in the system test. https://mirror.codeforces.com/contest/1654/submission/150264452 After the system test, I resubmit the same code. Then, I can get AC! https://mirror.codeforces.com/contest/1654/submission/150275130

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

[Deleted] I put the discussion under the editorial blog.

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

Why was my first AC submission for C was canceled ?

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

Can anyone help me explain why this code get tle on test 3 :(( https://mirror.codeforces.com/contest/1654/submission/150283548

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

In problem E, why use 50 as constant can solve the problem but bigger number cannot.

The right constant should be $$$\sqrt n$$$ ,isn't it?

I don't understand why?

My code https://mirror.codeforces.com/contest/1654/submission/150288568

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

I tried explaining my solutions for problem A,B and C . Link to the video

Hope this can be of any help.

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

The editorial is amazing! I hope all the editorial have "Hints".

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

nice problems.

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

Wait!Could you get into the editorial?

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

Can anyone tell me why my code got TLE please :/ It's only O(nlogn)

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

Does it seem strange to anyone else that F from this contest is rated 2800 while G is rated 2900? F was solved by 107 competitors in-contest, while G was solved by 10, which intuitively suggests that G is vastly harder than F; Carrot tells me the performance corresponding to 107th place is 2670, while 10th place corresponds to a performance of 3296. It seems to me that F is perhaps slightly overrated, but G is definitely highly underrated. (Admittedly, part of the reason G had so few solves is probably that it appeared late in the problem set, but even so, it's hard for me to imagine that the problem deserves a rating lower than 3100 or 3200.)