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

Автор FBI, история, 5 дней назад, По-английски

Hello Codeforces!

I am pleased to invite you all to participate in Codeforces Round 981 (Div. 3), which will start on Oct/24/2024 17:35 (Moscow time).

The format of the event will be like any Div. 3 rounds:

  • 6-8 tasks;

  • ICPC rules with a penalty of 10 minutes for an incorrect submission;

  • 12-hour phase of open hacks after the end of the round (hacks do not give additional points)

  • after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated

  • by default, only "trusted" participants are shown in the results table.

I encourage participants with a rating of 1600+ not to create new accounts but to participate unofficially.

Only trusted participants of the third division will be included in the official standings table. This is a forced measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:

  • take part in at least five rated rounds (and solve at least one problem in each of them),
  • do not have a point of 1900 or higher in the rating.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600 (or you are a newcomer/unrated), then the round will be rated for you.

Also, it will be a round with unrated register. If you already registered as rated participant you can change registration type here.

I would like to thank

Good luck!

Upd: Editorial is out.

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

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

Auto comment: topic has been updated by FBI (previous revision, new revision, compare).

»
5 дней назад, # |
  Проголосовать: нравится -43 Проголосовать: не нравится

As a participant, I hope everyone reach newbie after the contest.

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

cat

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

finally a div 3 after a month, lets go!!!

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

FBI!Open your mind!

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

I. WILL. REACH. PUPIL. AFTER. THIS. CONTEST ( else I'll quit cp touch grass and get a life )

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

How to get +200 in this round?

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

What the heck?By FBI?

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

Ciallo~(∠・▽< )⌒☆

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

FBI Contest!

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

As a participant... oh wait? I cant be? rip I have class at the time

Ill be sure to virtual tho

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

hope to reach pupil after this

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

Finally a contest with usual time.

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

As a tester, I would like to say the Chefir is a very interesting cat.

»
5 дней назад, # |
  Проголосовать: нравится -31 Проголосовать: не нравится

for what div3 ? to make it unrated how previous div4? #mike_fix_cdf

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

As a tester, I would like to say that all the tasks are interesting, and Chefir in the photo is very cute.

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

dog

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

Hello! I was a bit late with testing the round, I have sent a message with the feedback, but I am worried that my feedback won't be seen, so I decided to also leave a message here

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

Waga bakuretsu mahou wo kurau ga ii! EXPLOSION!

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

my max rating is 1190, hoping that i can achieve 1200+ after this contest

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

I think I can cross $$$1400$$$ before next Div. 4 round. Since, I opened the account, there's not a single Div. 4 Contest. However, attending straight into Div. 2 helped me to improve my skill quickly.

Anyway, What's the score distribution?

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

Can I go back to being a Pupil?

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

cat will help to increase rating

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

What a nice name--"FBI"...

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

As a tester, I hope no one will use AI

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

    Just a thought. Can't AI's just partner up with codeforces and not answer the questions during the contest?

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

      I think it is not that easy. If it was, it would be already ig. But it would be fine

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

Knock Knock !!!

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

To qualify as a trusted participant of the third division, you must: do not have a point of 1900 or higher in the rating.

did you mean 1600?

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

as a tester, this round has problems

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

My greatest dream has become a Div3 not at 17:35. I'm very busy at this time every day , All div3 at this time, why ?

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

Bro only sets Div 3!!!

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

LETS GET IT GANG!!!

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

eyuuuuuuuuuuuuuuuuuu

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

Can I pet the cat :)

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

As a tester, good luck have fun

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

cant wait to get Pupil rank!

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

Greetings Chefir!

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

As a tester, I respect Chefir orz

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

Могу ли я узнать, почему кота зовут Чефир?

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

Can you provide problems Rating Range?

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

I would love to see more photos of chefir

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

Is there a way I can submit during contest if I forgot to register before the contest started?

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

Thanks for problem B! In all seriousness how is it even possible to screw the problem statement that bad??

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

    I will be personally reading all your problems when (if) you will be hosting a competition someday. Have a great day.

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

      It seems like I was the only one that had trouble understanding the problem. But still I believe the statement before the change was bad and why you get offended(I know it is lot of effort to organize/make contest and I respect that)."It is known that at every point in the valley, the heights are less than 0","height of each spike","she can select a square area of mountains and increase the height of each mountain"...

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

      Why do you have to be pricky about it, bad is bad. You went from mountains to spikes in no time.

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

I was able to solve 3 problems for the first time in a CF contest :)

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

Nice F,G. No clue where to even start.

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

problem C is just wow.

i have no word

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

    authors can really surprise you every time with how bad they are at determining the level of the problem

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

    You just had to solve it from the middle of the array, not from the start!

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

      wdym

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

      could you tell me why my logic isn't working for problem C 287809023

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

        Although you are starting from the middle of the array, your approach is still wrong.

        The correct approach is to start filling a new empty array b of size n from the middle using array a. And calculate the disturbance in that array b.

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

How to do C??

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

    what i did. get all pairs. distribute numbers again greedily considering swapping a[i] with a[n-i+1] or leave them at their original positions.

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

      why does this work

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

        It’s based on a simple exchange argument proof. Basically, at each step you have 2 choices: swap a[i] and a[n-i+1] or not (dp works here too).

        Assume a=[3,3,7,5,3,9,1,7,4], and we are considering swapping a[1] and a[7], in this case, swapping or not leads to the same optimal answer we can get for a[0…2] and a[n-2…n] but this answer is independent of the optimal answers we can get for a[3..n-3].

        Therefore, we calculate the local optima we can get at each step hoping it leads to the global optima. Hope this helps ;)

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

    ll i(1) , j(n-2) ;

    while ( i < j) {
    
        if ( v[i]!=v[j] && (v[i-1]==v[i] || v[j+1]==v[j] )) {swap(v[i] , v[j]) ; }
    
        i++ ; j-- ;
    
    }
  • »
    »
    4 дня назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    If n is odd, ignore the middle element. Now take 2 middle elements,let their value be 'a' and 'b'. Let the element to the left of 'a' be 'c' and element to the right of 'b' be 'd'. Note that if a!=c and b!=d, this is best you can get(zero disturbances), so do not do anything, otherwise just swap positions of c and d, because this will not worsen the answer, the number of disturbances will either remain same or it will decrease, in this way move to the end points of the array. At last, you have the modified array with you, just count the number of indices where a[i] = a[i+1]

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

    what i did, fix the first pair of numbers, and then greedily order the rest, and then fix the first pair of numbers in the opposite way, and then again greedily order the rest. and then just take whichever of these 2 is better

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

    I did the following: swap $$$a_i$$$ and $$$a_{n - 1 - i}$$$ if either of these elements are same as their outer elements. By outer elements I mean the element just left of $$$i$$$ and just right of $$${n - 1 - i}$$$ respectively. The final array by iterating till the centre of the array is the optimal arrangement.

    Proof: Consider an optimal arrangement. we will show that any optimal arrangement can be transformed to our preferred arrangement without worsening the answer at any part of the transformation. Starting from the outermost pairs of elements ($$$0$$$ and corresponding $$$n - 1$$$), let's say the first relative order of elements we encounter which is not arranged according to our preference is between $$$x - 1$$$ and $$$x$$$. Now if we swap all the elements from $$$x$$$ to $$$n - 1 - x$$$, they will preserve their relative order, and thus the disturbance for all the elements in the segment. In fact the only thing that changes is the relative order between indexes $$$x$$$ and $$$x - 1$$$ and the corresponding pair on the other side of the centre. So the overall answer will only change due to the change in this part, which we can easily show, will not worsen if we swap it. We can continue to find such out of order indexes and swap them to our preference and none of these flips will worsen the answer.

    Thus, irrespective of the optimal arrangement, we can transform it into our exact arrangement, and the disturbance never got worse. Hence our arrangement algorithm in fact provides optimal arrangements itself.

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

      what is the difference between optimal and preferred arrangement ?

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

        By preferred I mean the arrangement that you propose to be solution, and the optimal is a hypothetical arrangement which has the optimal answer, but not necessarily same as your proposed arrangement. By the end of the argument the goal is show that the preferred solution is optimal itself. Note thatseveral different solutions nay all be optimal, you just need to show yours is one of them.

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

Was F really that easy (~1500 submissions)? I've been staring at the question for the last 1.5 hours and can't think of anything.

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

Born to make problems for div2. forced to make problems for div3.

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

Nice contest. Got to learn about fast doubling method in finding Fibonacci numbers in logn time complexity. Wonder if it could be used in F ? :/

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

Good job, guys. Very nice contest!

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

what's wrong in my F .

We just need to multiply Pisano period of k with n in mod ? Right .

I am Getting this 998488007 instead .

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

Even though I will be losing rating again, but great contest!!

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

Great contest, but sadly D is literally on leetcode

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

Implementation Forces

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

I solved F assuming that the period of "0" could be different, depending on the first term of the sequence ((0, 1, 1) is different of (0, 2, 2) for k = 4, for example), and this led tosome more unnecessary thinking and code, instead of just finding the first "0" and multiplying the answer by n. Now I see by bruteforcing all k's the period is always equal.

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

    can u plz share how did u find first 0?

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

    Sequence $$$(0, x, x, ...)$$$ is $$$(0, 1, 1, ...)$$$ multiplied by $$$x$$$, so period is the same ($$$gcd(x, k)$$$ is always $$$1$$$).

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

      This is making more sense now, if $$$gcd(x, k) \neq 1$$$ the sequence wouldn't be periodic (would never be "1" in $$$(mod\ k)$$$ again).

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

      You can also use $$$F_{s+t}= F_{s-1}F_t + F_sF_{t+1}$$$ to show that zeros are evenly spaced.

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

      Didn't understand how we're able to conclude that $$$gcd(x,k)$$$ is always 1

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

        Both $$$fib[n]$$$ and $$$fib[n + 1]$$$ are divisible by $$$d$$$, where $$$d = \mathbb{gcd}(x, k)$$$ and $$$n$$$ is position of first $$$0$$$. Using the Euclidean algorithm we can deduce $$$fib[n - 1] \mod d = 0 \implies fib[n - 2] \mod d = 0 \implies ... \implies 1 = fib[0] \mod d = 0$$$, so $$$d = 1$$$.

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

Am I the only one who swapped operations in G and ended up solving that for no reason xD

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

what is the follow up for F, i understood it will have a modular cycle, upon some search and reduction i can deduce the : nth fibonacci number as f(n) = (((1 1) (1 0)) ^ n - 1) * (1 0), but how to make progress with this. Any help will be appreciated.

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

    for all k, we can find the first "0" element by linear number of calculations. I bruteforced all k's from 2 to 100000 to find out the maximum number of operations, and that's always lower than 2*k (Didn't prove the general case). For some reason this period is always equal for all k <= 100000 too.

    Here is proved by AC 287807845

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

What's the order of swapping in 3rd question or simply what was the logic behind this question, I tried a lot but didn't got the answer.

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

Great contest, mainly E, still figuring out how to optimise E..

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

When does the Editorial will publish?

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

The problem statements were so poorly worded and sample I/O was not explained. For example, in problem B, you talk about mountain and then suddenly ask at the end about spikes. Mountain is defined to have positive height, but a square of mountain can have lakes (that have negative height). Why even write a legend if you cannot be consistent about it in the very problem statement? sigh

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

    I have the same thoughts, the spikes confused me a lot, and I wasted 15 minutes trying to understand it.

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

F was a sadistic problem

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

What the hell is problem C

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

For E. I got TLE on TC 5, how can I further optimize this?

Submission: Link

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

Please add a note or explain at least one of the test cases. I am not asking for an explanation on every test case of the question, but as a beginner, some questions can be challenging for me to understand. I often look through the test cases and notes to get an idea about the question. Again, I’m not suggesting you add explanations for Problem A; I suggest starting with at least Problem B.

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

Any hints on C and D? My brain is deep-fried and cannot think clearly anymore

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

    C : Think of a swap as penalty increase, no effect on penalty or penalty decrease. Penalty increases after a swap if the ai != ai+1 and we swapped in a penalty value. So we only swap when ai = ai+1 as it will either decrease penalty or will keep it same. I don't know how to explain better than this.

    D : Prefix sum map int -> int. store the last index where the sum appears. Iterate from beginning and if you find some sum again update its last appearance and increment ans.

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

      damn I miss the map part... I was completely stuck at D and have no mood for C. Actually thought the same idea but have no time (about C)

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

      I can't solve C, can you explain or hint more?

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

NEED MORE DIV3s PLEASE CF-SAMA

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

Greedy Forces

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

who else when $$$k=1$$$ printed $$$n$$$ instead of $$$n$$$ $$$mod$$$ $$$10^9 + 7$$$ ?

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

f is easy to find in google, d < c, excellent round, thanks fbi, now i prefer the KGB

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

G : Try to solve offline....... For a pair ( v , k ) , find node k distance up from v , now if I go up to a node x , ans of query can be level[v] + ( "distance of deepest leaf node from x found so far" — level[x] ) . we can create a array on the basis of inTime of nodes , and use it to find maximum in a range from l to r using a max segmentTree . l : inTime[u] : u nodes after k jumps up from v ( use binary lifting to make it fast ) r = inTime[v] .As soon as a node is done , update its value with — inf in segmentTree

Just want to know is it somewhat related to Heavy Light Decomposition.

Sorry for my weak English

Refer to code

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

what is the solution to F?

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

    Just find first index of fib for which $$$fib[ind]\%k = 0$$$ and then $$$ans = n*ind$$$. That's it

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

      I see, thanks. So do the zeros always repeat after a set amount? And is there a proof for that?

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

        yeah they always repeat like for 4 after every 6 it will repeat

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

        Yes. After the first index where rem=0, the reminders tend to again follow the fib sequence from the beginning

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

          It seems like some of them aren't the Fibonacci sequence exactly, but eventually it goes back to a Fibonacci sequence after a few zeros. Like this is how it is for $$$5$$$:

          5

          After $$$4$$$ sub-turns, it eventually went back to $$$1, 1, 2, 3, 0$$$ and just continues looping through the $$$4$$$ sub-turns.

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

            Yeah, it's not exactly fib sequence, but multiple of fib sequence and the multiple is not a multiple of k so it doesn't actually affect the period of 0

            After first 0, its $$$3*(1)\%5, 3*(1)\%5, 3*(2)\%5, 3*(3)\%5, ...$$$

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

        The period of multiples of k will not exceed 6*k wikipedia

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

for E, if you also have to print the swaps, then it's similar to https://cses.fi/problemset/task/1698

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

C is incredibly hard as a 3C

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

Fidelity Bravery Integrity

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

greedyforces. guessforces. readforces.

pA: The problem statement is so long that I need a lot of time to read the statement. Also, no explain testcases makes me more confused. I can't understand who wins on problem A, and I need a lot of time to read the statement again and again. I also don't like the output of A, why not just output yes/no instead of the LONG name?

pB: "If aij<0, then THERE is a lake THERE". Why 2 THERE in the same santence? "With her magic, she can select a square area of mountains and increase the height of each mountain on the main diagonal of that area by exactly one." The sentence is too long, u should split the sentence by "," and ".".

pC, pD, pE, pF are all GREEDY. Why put so many greedy in a contest? To make people guess the ans again and again? pF is the most painful problem among them.

To do pF, we first need to guess that there is a cycle of the remainder of k. Then, guess the upper bound cycle length is bounded by a multiple of k. We just guess everything in pF, that's stupid. Also no need for a ll n in the input, which makes me lose my AC for k=1. Honestly, What do we learn from this problem? Guess? Take care for output of k=1 bcz n is too big?

I learn nothing from this contest. I just guess and guess all the ans from all the problems. Problem statements on pA and pB are fxxking long and really weird, which made me suffer. We DO need the contest to test our CP ability, instead of reading problem statements/guess the ans/avoid the unnecessary traps.

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

    If you think greedy is guessing, then maybe you can try learning how to prove your greedy solutions ;)

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

      no, proofs are too hard, i think he’s better off improving at guessing

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

        thats true for increasing your rating, but he mentioned he learnt nothing from the contest, and trying to prove any greedy solution is of course an enlightening activity.

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

          Yeah, try to prove the greedy of F. That may need a lot of papers. Nobody cares about the proof of greedy during the contest, and also nobody will prove the greedy after the contest. I am just telling the truth.

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

            F is not even greedy lmao

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

              Not greedy, sorry for the wrong word. I mean to guess everything in F. No proof can be provided during the contest, and that remainder property of Fib is not useful in CP.

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

                Yea well I do agree that thinking about proofs is bad during contest. But thinking about it post-contest can actually help improve your intuition so that you can guess better next time. As such, no problem is useless you have seen it before :)

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

    Generally agree your perspective on the extremely boring A, B, D and F with awful statements or ideas. But it seems that C can be solved by linear DP and E can be abstracted into a relatively interesting graph problem(about how to optimally cut the long loops). However despite the multiple solutions, this round is still too relied on key observation and guessing as you just said, and F is the most weird amongst all the unreasonable ones. It's just like a guessing game rather than a true algorithmic problem combined with number theory.

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

    I read the problem A half way, saw the test cases and assumed (idk why i risked it) that its just odd/even and AC.

    B was stupid too, I was baffled by the lengthy and confusing statement. C was also not clear in the first instance. went straight for D. really a guessforces.

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

      even i guessed it but still wanted to verify it, there is often bias about these A,B problems.

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

    I feel better after using DP on C instead of greedy. The problem has a single observation to pair the disturbance of i with the disturbance of n-i, instead of n-i+1 as one initially does. The problem also leaves behind one of the repeating pairs count in the description to allow this. You need this "creativity" to solve the problem, regardless of what everyone else says about "proving greedy" or whatever. Fundamentally, it's about math creativity. This means that for the front half of the elements we pair with the element in front and for the back half we pair with the element behind. In doing this the problem of [2,n-1] becomes a subproblem of [1,n]. Then DP follows.

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

      Both DP and greedy have optimal substructure. If u find some optimal substructure, and say that "This problem is DP", then u are totally wrong. "creativity" is indeed greedy choice property.

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

loved it I got the idea of F but couldn't implement it out as I didn't focused that we just can brute forced it out man but was a great contest for me

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

hmm

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

I was able to solve problem 2033F - Kosuke's Sloth by making an observation that numbers divisible by k occur at regular intervals in fib sequence (I don't know why)

https://r-knott.surrey.ac.uk/fibonacci/fibtable.html

Then you have to find first index i where fib[i]%k is 0 and another observation I made is that this index i is always less than or equal to 2*k. You simply multiply this index by n to get index of nth element divisible by k.

if you see the table in mentioned link, you will observe indexes —

divisible by 2 — 3,6,9....

divisible by 3 — 4,8,12....

divisible by 4 — 6,12,18.... (huh?)

divisible by 5 — 5,10,15.... (why?)

divisible by 6 — 12,24,36... (what?)

Is there a way we can find the first index using k itself?

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

    there is a fact about fibonacci numbers which says that if n divides m => fib(n) divides fib(m), so using this you can see why that property is true

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

    Brute force, since k <= 1e5

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

      That's what I did but there must exist some formula that directly gives us the first index divisible by k using k only. That is, f(1)=1, f(2)=3, f(3)=4, f(4)=6, f(5)=5, f(6)=12 and so on.

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

        I missed the constraint on k and was trying to calculate it based on $$$m=p_1^{e1}* p_2^{e2} * ... * p_n^{en}$$$ then $$$a(m) = lcm(a(p_1^{e1}), a(p_2^{e2}), ..., a(p_n^{en}))$$$ and $$$a(p^e) = p^{e-1}*a(p)$$$, found those on OEIS

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

B's Statement is too long for 3B

C is hard for 3C

D is somewhat classic

I think F was in hand , if we just had better set and statements

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

What is the idea of E?

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

    You can visualize this as a directed graph where every node i is connected to node P[i]. The given conditions will be satisfied only when all cycles in this graph have a length of 1 (that is i = P[i]) or 2 (that is P[i] = j and P[j] = i).

  • »
    »
    3 дня назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    Hint 1
    Hint 2
    Solution
»
4 дня назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

Is it just me, or did anyone else implement G , such that if you move from child to parent, your stamina doesn't decrease, but when you move from parent to child, your stamina decreases.

( basically, direction of travel was reversed :| ) .

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

    but even after that how to solve it?

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

      when we do it in reverse, I guess question becomes even more difficult than the question that is already asked.

      The question that is asked, for that I guess DFS + Segment tree is enough.

      The question that I was solving, we need to maintain monotonically increasing set of nodes, which always improve the answer.

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

        Can you guide me to the solution? How do I start with this one?

        Can we use dfs tree flattening? we can go upto k parents up, then we just want to figure out the farthest node from i within that subtree.

        Is this approach useful? too complicated? any help would be appreciated.

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

          Lets define few terms,

          1) Level of 'node' is equal to distance of current node from node-1.

          2) Maximum depth of the node — in the subtree of given 'node', what is the maximum length of any chain.


          Now do 2 parse DFS .

          First DFS

          In the first DFS, you can keep track of level of node, and maxDepthOfTheNode ( You just need to keep track of two maximums ) .

          Second DFS

          When we travel from 'parent' to 'child' node, we have to find, what is the maximum length chain, that is starting from the 'parent' node, and doesn't pass through 'child' node ( basically passes through sibling of the current child we are exploring ). You need to insert this value in the segment tree. ( Point update in max-segment tree).

          Then it is simple range query for last 'k' elements of the Segment Tree.

          Hope this helps.

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

    i thought that at first when i read it, but thats fairly trivial. edit: its not that trivial actually nvm

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

      IMO, the implementation is little tricky when we do it reverse. The implementation is very straight-forward, if you have max-sementTree template.

      The reverse of the question, was little edge-case involving.

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

        yea i just started thinking about it, and i just realized its not actually trivial at all. i believe segment tree is needed for both of the versions, and sadly i have no idea how to implement it or use it so i can only wonder :(

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

          I was unable to figure out, how the segment tree would help in reverse direction. Please elaborate idea. What values would you store in segment tree ?

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

            It is solvable and i solved it during contest before realizing I alongside 100s of others made the same misreading

            Solution : as in the other solution, we assume we have d_i a depth array calculated where d_i represents deepest node in subtree of i'th parent of v (which is not present in subteee of (i — 1)th parent of v)

            Now, we want to find the maximum of expression

            $$$i + min(d_i, k)$$$

            Find the last index $x$ where d_i >= k using Walk on segment tree. Then, either optimal index is $$$x$$$ or one of the indices $$$x + 1....$$$

            Calculating value for $$$x$$$ is easy, and for $$$x + 1...$$$, you can note thar the function becomes $$$i + d_i$$$ because $$$d_i < k$$$, and the segment tree we are already using for this version of the problem suffices

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

              exactly what I did bhai... But instead of using the segment tree, I had used monotonic set of nodes, which will always improve the answer. and then applied lower_bound search on those. couldn't think of SegTree based solution.

              Code for reverse direction

              While running sample test cases, I realised, I am screwed. Although it was good problem to solve.

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

can anybody tell why the code for G problem of this contest is giving tle its complexity is (n+q)logn https://mirror.codeforces.com/contest/2033/submission/287818878

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

I am sad

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

For the problem f, The proof of the solution is

Let F(i) be the first term when F(i)%k == 0, then the series from the ith term modulo k for every term (F%k) onward will be like F(i-1),0,F(i-1)*(1), F(i-1)*(1),F(i — 1)*(2), F(i — 1)*(3),... F(i-1)*F(i)

Now, we can can say that F(i — 1)%k != 0 since F(i)%k == 0 as we assumed, therefore the 2*ith term which is F(2*i)%k = F(i — 1)*F(i),.. Now carrying on forward, we can say that i,2*i, 3*i, 4*i,... will be the term when F(i)%k == 0.

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

    This is nice, but how do we know that there is no zero in between $$$F(i)$$$ and $$$F(2i)$$$. I was wondering what if $$$F(i-1)*F(j)$$$ is a multiple of $$$k$$$, where $$$j < i-1$$$

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

      The Fibonacci sequence modulo k is known to be periodic, with the period length called the Pisano period. This means that Fibonacci numbers modulo k will eventually repeat after a fixed number of terms. Once the sequence reaches F(i) (the first number divisible by k ), the subsequent terms follow a predictable pattern.

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

    Its a little unclear still. Can you explain a little more?

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

        I read pisano period. But pisano period just says that there is a cycle. Not necessarily that the 0s also cycle.

        What if there are two zeros but unevenly occurring in the cycle, then the 0s don't cycle.

        For ex: Let's say the cycle length if 5 and the first, 4th and 5th number is a 0. Then the 0s don't form a cycle.

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

For the problem F ,

what is the proof for the following fact : I brute forced for all prime's up to 1e6 (p) to find index of the smallest fibonacci number that is == 0 (mod p)

here are the values up to 100

as you can see the value is at most n+1 , that allows for submissions like rainboy's to pass as they just naively find the first fibonacci number which is == 0 (mod k) and multiply it by n.

Does anyone has a proof for this , why does this work ?

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

C was too hard for a div3C, totally made for guessing the solution. In D, you could have explained what you meant by non-overlapping, do you consider (a,b) and (b,c) to be non-overlapping? or do you consider (a,b) (b+1,c) to be non-overlapping? Its the former,which i got to know after a WA.

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

    totally made for guessing the solution

    Disagree with this. If you start solving the problem from the middle, the problem becomes quite simple I believe. If we consider the even case, we can fix the middle two elements in any order, because no matter how the middle two are arranged, we can always adjust the rest of the elements relative to them. Now once we fix the middle two elements, we start moving outward. Suppose we are at $$$l,r$$$ currently, now we just need to compare with elements $$$l+1,r-1$$$. If swapping $$$l$$$ and $$$r$$$ results in a better answer than not swapping, then we should definitely swap them. Instead of just swapping $$$l$$$ and $$$r$$$, think of each step as swapping the entire prefix till $$$l$$$ and the entire suffix from $$$r$$$ onwards. If we think of it this way, one can see that only the relationship between $$$l,r$$$ and $$$l+1,r-1$$$ is changing, everything else stays the same. Hence, it is always enough to look at the immediate inner neighbors, and swap if it improves the answer.

    I'm a little surprised that this problem has barely more solves as E. I was a tester and when I was giving virtual contest, this was actually problem B. While I did feel that this might be a little hard for a B, didn't think it's as hard as E.

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

      instead of just swapping land r, think of each step as swapping the entire prefix till l and the entire suffix from r onwards

      Could you explain this more?

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

        did you get it ?

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

        Assuming we have an array of 6 elements:

        a1, a2, a3, a4, a5, a6

        We can actually fix the middle two elements in any order because the two middle elements are a3 and a4. We can place a3 on either the left or the right. Wherever we decide to place it, it won’t affect our future choices because we can choose a2 and a5 however we want in the future. So, if a3 in the optimal arrangement should be before a5, we can leave a3 in its place and then swap a2 and a5, which will have the same effect as swapping a3 and a4.

        That’s what he means by prefix and suffix. If you decide to swap L and R, then whatever needs to be a neighbor to L after it’s swapped can still be its neighbor, and the same applies for R. disclaimer : I wrote this comment to better understand the problem myself so I might be Hallucinating

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

      I started from the beginning. The order of the first and last elements do not matter, so put them in any order. Then, while filling the positions (l, r), I compared them to the elements right outside (l-1, r+1), the position I filled in the previous step. This works, but I do not know why.

      Previous to this, I tried swapping each position and comparing whether disturbances decrease. I compared l with both neighbors (l+1, l-1) and r with (r+1, r-1). I got a score out of 4. If swapping decreases this score, then swapping is optimal. Else it's not. This did not even pass the sample test cases. Any idea why?

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

        because you are comparing and determining the current greedy optimal with something that might be changed in the future (l+1,r-1)

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

Can someone please hack this solution?

https://mirror.codeforces.com/contest/2033/submission/287788123

Thanks!

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

    i doubt that anyone can, youre essentially just breaking down a big cycle into 2-cycles or 1-cycle, which is optimal.

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

      Yes, but I thought that since I am using map, so maybe there might be some testcase that can cause a TLE? 1983ms runtime on a qn with 2s limit seems hackable no?

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

        yea it seems so, but im not really sure what makes it so slow in the last test. it seems that no matter the input, you will always do (n-1)/2 operations which means you will be accessing the map that many times, and i tried to hack like that, but that passes in 500ms. maybe when you have multiple test cases and make a new map and initialize it all over again or something like that

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

Guys what would you suggest to learn or what do you think should be the mane focus on people like my that make it till problem B in div 2 and div 3. Like I know what DP is or Recursion. I've learnt about this topics and can I know on what field to use them but when I get a problem I have a great visualization on what to do but as soon as I get on to typing the code I get lost in stupid shit. What is your suggestion on solving this

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

why so many D's are getting Hacked ??

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

    Because of unordered map I think.

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

    Overflow/underflow problems, I assume. You need to use a 64 bit integer map/set key as n = 10^5 and ai can be in range -(10^5) to 10^5, so total sum of a can be -(10^10) or 10^10, which are respectively less than INT_MIN and greater than INT_MAX. As such, I believe solutions that use a 32 bit integer map/set key will be prone to hacks.

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

      Below is a generator for hacking people storing their prefix sum in map/set with 32 bit integer key. It causes an overflow which results in the integer value '32704' to be stored in the map, then carefully adds negative integers until a final value is added to be equal to '32704'. This causes the bugged code to falsely find a prefix sum which doesn't exist in reality.

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

    Yeah, mine too got hacked.

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

Can someone please hack my solution for C?

287837237

I just did mindless greedy.

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

div 3 more like div 2 lol

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

guys my solution got hacked, and i dont really understand how, and what is wrong with it, i'm new to codeforces, can anyone check and tell me why did it got hacked?

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

Does anyone know how to approach problem F intuitively without any googling or guessing the idea. Like ok maybe I can guess the first occurrence of zero must be periodic for all zeros, but how to prove this simply?

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

    This is how i solved: First observe/guess that when you find the first number divisible by k, its just periodic and every x-th number is divisible by k. Then I try and calculate the first k fibonaci numbers and assume that its enough to find the first divisble number. That fails on test cases, but k+1 passes, so i submit. Get WA on test2. Ok so lets just assume that we can calculate it in some y*k time where y isnt too big, and if i just calculate until i find it, it should pass time limits. Submit and get AC.

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

      Ya I thought of that in contest, but here you are still making the guess that after you find the first divisible by k number, you then just output n*k. Is there a proof on why this 0 must be periodic? Like maybe let the first position be x, how do you know there is not also a 0 between x and 2x? This is the uncertainty I had in contest which made me hesitant to submit.

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

huge part of solving problem C is realizing that it's a div 3 C which is a skill that only needed in code forces

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

    After upsolving this div3C I actually doubt I'm a pupil (Dropped to newbie after this contest). Time to climb up the rating again...

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

      I upsolved also but still didn't learn anything from it there is this comment which I couldn't understand yet but I will try more

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

        Yes, we need to try to get better. The newbie-pupil struggle...

        Btw the comment of that tester actually correct/good instinct. Good note

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

whats the point of questions like F that require some kind of math theory and code that can be easily generated by gpt. I can assure you atleast 80 percent of the people who did it googled/GPTed it.

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

    git gud and stop crying

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

    FYI, googling things is not considered cheating

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

    I solved it with a pen and a notebook in $$$7$$$ minutes (though not fully giving concrete proofs before coding, trusting my intuition), so umm.......

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

      can you go through your thought process? Did you prove the existence of pisano period in 7 minutes?

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

        Disclaimer: As said, I didn't fully prove it. It's just how strong an intuition proved to be in my mind to assert confidence.

        First, I see the periodic repetition in the sample, and the really questionable answer for sample case 3 (so close to mod, and given 1e18 was there, the operation should be something pretty simple).

        Then, I turn the notebook and draft some $$$k$$$. It dawns on me that it's truly periodic, except for $$$k = 2$$$ there's never a $$$[0, \frac{k}{2}, \frac{k}{2}]$$$ subarray in the modular sequence. The most concrete fact that pushes me into immediate coding is that Fibonacci sequence doesn't really take divisors into account, so in the perfect world, it should be something close enough to a normal random distribution of modulus, rendering the linear nature of the period size.

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

    I got my idea without googling I generated the Fibonacci sequence to check till 20th number and found that there will be cycle which is a fact I got to know later, but I couldn't implement it out in the contest

»
3 дня назад, # |
  Проголосовать: нравится -12 Проголосовать: не нравится

why did div3 not allow rating???

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

too unfortunate this 287855687 get wrong on problem C. I was soo close

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

good round, solved upto D hoping for pupil soon

got hacked on D for using unordered map though, upsolved using set.

overall a good performance on my part, performance of around 1200 (after hack), 1350 (before hack)

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

why aren't people using two pointer to solve C

It's the approach I got during the contest and it's been accepted. After seeing post contest discussions I see a lot of people saying it should be solved using DP.

I will upsolve but I don't understand why didn't a lot of people solve it using two ptr during the contest.

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

I Will become a specialist in this contest. Lets go!

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

why contest unrated?

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

Can someone help my G? I don't know why I got TLE on test 8, plz. 287869462

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

For F: https://www.geeksforgeeks.org/nth-multiple-number-fibonacci-series/ Added a few modulos and raised max n and got AC

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

    I was trying to find this code during the contest but I was not able to and couldn't implement out my idea :(

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

I was hacked in problem D. I already was unhappy by my performance in that since I was so close to submitting E, I derived the cycle but then failed on figuring out that it would (k-1)/2, I was trying k/2. But then D also got hacked because of something I can't figure out

Anyway,

I submitted this using an unordered_map which got TLE and was hacked :(

void solve() {
	int n;
	cin>>n;
	vll arr(n);
	cin>>arr;

	unordered_map<ll, int> mp;
	ll sum = 0;
	int ans = 0;
	fori{
		sum+=arr[i];
		if(sum == 0 || mp[sum] > 0){
			ans++;
			mp.clear();
			sum = 0;
		}else{
			mp[sum]++;
		}
	}
	cout<<ans<<endl;
}

Then I submitted using a multiset which got AC.

void solve() {
	int n;
	cin>>n;
	vll arr(n);
	cin>>arr;

	multiset<ll> mp;
	ll sum = 0;
	int ans = 0;
	fori{
		sum+=arr[i];
		if(sum == 0 || mp.count(sum) > 0){
			ans++;
			mp.clear();
			sum = 0;
		}else{
			mp.insert(sum);
		}
	}
	cout<<ans<<endl;
}

Isn't a mutiset slower than unordered_map?

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

guys that was my first contest and i've solved only one problem (first obv) and will i get rated after this?

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

Given the number of successful hacks for Problem D , it is so that deliberately the tests are weak so that the contestants can hack each other's solution and earn points?? JUST A POV :)

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

For problem E came up with this solution though cannot prove it and didn't manage to submit by some seconds :-))

Unfold

This basically tries to make permutation and "reverse-permutation" equal in <= N steps.

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

I got tle on test case 49 of D even after using custom hash in unordered_map.

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

I think question G is better than question F, question F can be written quickly by guessing the conclusion, and question C is also more difficult than question D and E.

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

When will the Rating's Be updated

is there any site that give the expected ones out

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

Oh, NO. I want to regist but late!!

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

1259 still newbie T_T

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

Arghhhh, why is https://mirror.codeforces.com/contest/2033/submission/287918494 TLEing for G? It's literally segtree + dfs which I hope is intended solution.

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

what is the logic behind G

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

UPDATE: the solution is correct except for the way I define the end of the range on which I calc dp table,
For example, if n = 5, we need to calc dp for 0, 1, 2
and if n = 4, then we need 0, 1 simply it's half-interval [0,ceil(n/2)) NOT [0,floor(n/2))
This line is wrong int limit = n / 2;

I tried to solve C with dp.
The idea is
dp[i][0] -- min shit in prefix [0, i] and corresponding suffix IF we do not swap at i
dp[i][1] -- same but if we do a swap at i

Clearly, or so I think, dp[i+1][0] can be computed from dp[i][0], and dp[i][1], same for dp[i+1][1]

But my code is not outputting correct result. Can someone help me identify the bug? is the approach wrong? or some bug in the code?

https://mirror.codeforces.com/contest/2033/submission/287926217

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

can anyone help me to get out of this i solved problem D during contest but it get's wrong answer on 9th test case while checking on updated test case then i change my data from int to long i though that might be the cause but now it is giving tle on test case 16 please help here is my code ````````````````````` int n = in(); long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = inl(); } int cnt = 0; long pre = 0;

HashSet<Long> hs = new HashSet<>();
hs.add(0L);
for (int i = 0; i < n; i++) {
  pre += a[i];
  if (hs.contains(pre)) {
    cnt++;
    hs.clear();
    hs.add(0L);
    pre = 0;
  } else {
    hs.add(pre);
  }

}

out.println(cnt);

````````````````````

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

Can anyone help me with my submission for D, I use Java and I've noticed that I am getting tle if I use map.clear() in submission 287709751 but if I re-instantiate the map 287930490 it gets accepted.

Upd: Got it clear function just sets all entries to null by traversing the array and the size remains the same.

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

How can C be solved with binary search? I am asking because I noticed that problem C tags involved binary search for some time.
Also, I am curious to know how these tags are added. Is it detected somehow automatically from submitted solutions? I noticed that after I submitted my dp solutions, the dp tag was added again.

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

    Tags are added by people that can be "trusted" to handle tags properly, and by "trusted" I actually just mean people above a certain rating (I believe that would be CM)

    There actually was an instance when people mass-spammed tags on the D problem, and a similar thing likely happened on the C problem on a smaller scale.

    Circling back to the first question, if a binary search solution even does exist it would be slower than the intended solution for C (as shown in the editorial).

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

I was stuck at Verifying whether you are a human screen for more about 10 minutes. I tried giving the contest on mirror websites but for some reason, the problem statements weren't available. What is the point of having mirror websites if you can't access questions on them? By the time the page finally loaded there were already more than 7000 submissions on problem A

Such incidents of 1. Website not loading 2. Being stuck on the "Verifying if human" screen 3. Website crashing multiple times are getting more and more frequent.

MikeMirzayanov Look into this matter

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

How to solve G? Thank you

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

    Note that you can go to K-father from a vertex, and the answer is contributed by any vertex and the path of K-father.

    Let's define $$$dp_i$$$ means a vertex can go to its deepest son of $$$dp_i$$$ length, $$$cdp_i$$$ means a vertex can go to its the second deepest son of $$$cdp_i$$$ length(The paths do not intersect).

    You can get a new array $$$len_i$$$ means the longest path that the father $$$u$$$ of $$$i$$$ can reach without passing through $$$i$$$. It's either $$$dp_u$$$ or $$$cdp_u$$$.

    Now we want to know how long he could go. Note that $$$i$$$'s father $$$u$$$ contributes $$$len_u + 1$$$, $$$i$$$'s father's father $$$v$$$ contributes $$$len_v + 2$$$...

    So if we design $$$len_i$$$ as $$$len_i - dep_i$$$, our mission is to get the $$$\max$$$ on the path from the vertex and its K-father. When get the maximum of the path, add $$$dep_i$$$ back. Remember we have another choice is to go to the vertex's son. Just take the maximum value. Then use multiplication algorithm to solve it!

    This is my submission 287948215.

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

It confused me a lot. I thought my submission 287933697 is totolly $$$O((n+q)\log{n})$$$. Why I got TLE?

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

how did i do d,e,f but not c

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

How on earth is it possible? Problem D, TLE with std::unordered set but works all fine with std::set?

TLE-with-unordered-set

Okay-with-set

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

Hi till when can we expect the text editorial ? Thanks ! @FBI

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

Auto comment: topic has been updated by FBI (previous revision, new revision, compare).

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

Hello codeforces Headquarters, Vladosiya,

I received an email about a rule violation, specifically about the coincidence of C code. I was surprised that someone wrote the same code as me.

I can only explain this as a random similarity, because the way to solve the C problem is very limited and simple, I also did it in Python, a simple language so the coincidence is very likely to happen.

I commit that I did not violate the rules.

I really hope that there will be a fair assessment and treatment for me.

»
24 часа назад, # |
Rev. 2   Проголосовать: нравится -17 Проголосовать: не нравится

Hello, Codeforces Headquarters, Vladosiya ,

I would like to report a false accusation of cheating regarding my code for the last Div.3 E problem.

My code works by checking each unvisited index within a cycle, marking it as visited, and counting the cycle's length $$$(c)$$$ . If $$$c \ge 3$$$ , we need to perform swaps, as each swap reduces the cycle length by two. This results in $$$\left \lfloor \frac{c - 1}{2} \right \rfloor$$$ swaps being necessary.

(I think I've to make screencasts to avoid this ?) + (I've solved some similar problem somewhere)

Please take this into consideration

Thank you.