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

Автор 74TrAkToR, история, 7 месяцев назад, По-русски

Привет, Codeforces!

Я рад пригласить вас на мой Codeforces Round 904 (Div. 2), который пройдет в 22.10.2023 10:05 (Московское время). Он будет рейтинговым для всех участников, чей рейтинг будет ниже 2100.

Задачи были придуманы и подготовлены 74TrAkToR. Хочу поблагодарить всех, кто оказал бесценную помощь в подготовке этого раунда:

На раунде вам нужно будет решить 5 задач. У вас будет 2 часа на их решение.

Разбалловка: $$$500-1000-1750-2500-3000$$$

Желаем всем удачи и высокого рейтинга!

UPD: Разбор

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

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

As a tester, omg round by coordinator.

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

Why multiple contests on same date ?

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

Why are ratings 1600-2099 so lucky they can participate in two Div.2 competitions.

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

The problems are very good. Hope you will love solving them. (:3 first time testing)

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

I'll never forget exciting rounds coordinated by you. Hope the round will be fine.

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

Looking at the score distribution this seems like a speed run. Gonna register with the motto Don't participate if you can't dominate.

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

    Looks like the difficulty of problem D is going to be harder than usual

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

      What do these points mean? is there any correlation between points and problem rating?

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

        Generally I have seen Prblm D to be at max of 2000 points, so keeping points high will most probably mean higher difficulty

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

But why two div2 rounds on the same day?

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

Deleted

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

pshat orz

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

Only five questions and the score distributin is also high why so?

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

you forgot NOTE THE UNUSUAL STARTING TIME in bold to make people aware

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

Why is the registration for Codeforces Round 905 (Div. 2) saying "Rating should be between 1,600 and 2,099 in order to register for the contest"?

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

I think it's better if you write in the post that only >1600 can register and get rated

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

    This is Round 904. Rated for everyone below 2100. You are talking about Round 905

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

      Yeah but even the registration page of Round 904 says that I'm registering out of competition... probably it's not mentioned properly in the announcement, or it's a bug.

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

Seems like Codeforces Round 905 (Div. 2) gonna be blue-purple war!

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

I really like this timing.

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

Why is it said here that the competition will be for rated participants with a rating of no more than 2100, but at registration this is a rated competition for participants with a rating from 1600 to 2099

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

Это какое-то новое правило, что див2 можно писать только с 1600?

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

I guess at CFR904 and 905, there will be chaos because of the back-to-back rounds and tricky format of CFR905. So I suggest some unusual rules for them:

  • The rating change of CFR904 won't be updated until CFR905 ends so that avoiding double-register (and getting double-rated mistakenly) for CFR905
  • Everyone is rated by the division in which they registered even if the participant gets division promotion from CFR904.
    • Another choice is to update the rating rapidly and remove double-register before the round starts.
  • Rated participants of Div1 or Div2 of CFR905 should be kicked out from Div3 of CFR905, Otherwise some penalties will be avoidable by submitting their solution for Div3 first.
  • Open hacking is disabled for CFR905(Div3). Only div3 participants get open hacking is unreasonable unless the problemsets are disjoint.
    • Another choice is to introduce open hacking for all 3 rounds. Anyway, I don't like the parallel rounds with different rules without suitable reason.
»
7 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

When the registration for division 905 will be open? Usually I get an email with invitation.

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

Why there was said in the announcement that "this round will be rated for all the participants with rating strictly less than 2100.", but there was said in the register page different "You are registering "out of competition", reason: rating should be between 1,600 and 2,099 in order to register for the contest"? I'm getting confused, can anyone help me to figure out it?

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

    There was a mistake on my side setting up the round. Now everyone below 2100 should be able to register as usual. I'm sorry for the inconvenience. We'll automatically change the status of already registered and having rating below 2100 to official contestants before the round, you don't need to do anything.

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

The rating changes for a round are sometimes cancelled and then recalculated, which takes about 1 day.

Round 905 starts just 2 hours after round 904 ends. Consider the following situation.

You participate in round 904, your rating changes, and then you participate in the corresponding division of round 905. After a few hours, rating changes for round 904 are cancelled and recalculated, causing your division to change and meaning you haven't participated in your division of round 905.

The chance of this happening is very small, and it's interesting to know what would happen in this case.

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

Why there are so 2 contests on the same day?

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

I registered in both 904 (in div 2) and 905 (in div 3). In case, for 904 my rating increased to be >=1600 and rating update happens before start of contest 905 but after registration end time. So in this scenario, will my registration in 905 as div 3 still be considered valid even if my rating now becomes >= 1600. Wont it create any confusion?

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

(13-21) — 9 days 0 contest. (22) — 1 day 4 contest!

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

Why there are 4 contests in one day, and for the next week there's no contests?

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

would love to have more rounds like this that are not late in the night(in my country) :)

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

Hoping to become CM in this contest!Only 9 ratings!

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

It's time to rage(100%)

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

Please note the non-standard start time for the round

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

This is my first contest. Can i join it?

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

Yes, I love you too;

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

Dangerous round 3rd & 4th questions will be difficult as the points are very high and 1st question is of 500 points which is more than some earlier rounds. ( Means div 2 B === this round A)

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

More suitable for Chinese baby constitution

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

So intersting

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

Hats off to US contestants who will join at 00:05 am and 04:00 am today.

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

Nice start to a Sunday afternoon (╥﹏╥)

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

How to solve problem C?

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

      Can you please elaborate the solution for Problem :C ..

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

        lets fix some point P, and make a[P] max, how we can guarantee that it will be max? to do it we can use only segments which are l[i] <= P <= r[i], then find min and max for this.

        we need to do it for every important point, we can find this important points after compression l and r. but it is O(n^2) which is too slow

        lets add and remove segments greedily, and to do -1, 1 operation with lazy segment tree, and find min max also with it, so complexity will be O(nlogn) because we add every segment only once and remove also only once

        upd: actually using Lazy segment tree is overkill

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

        suppose some point is the point with the maximal value(call it p1), then only segments that pass this point are relevant. because for any other point that may be the minimal point(call it p2), segments that only pass p2 are obviously necessary to delete, and for those who passes p1&p2 at the same time, we won't have to delete them, since they dont affect with the outcome of v(p1)-v(p2).

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

    Maximum number of overlapping segments that don't end in $$$m$$$, or maximum number of overlapping segments that don't start in $$$1$$$. I have 5 lemmas to prove this, and it passed system tests.

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

    First sort segments by increasing left border. Then go through them, maintaining a priority queue of the right borders to determine when a segment goes out of consideration. We can observe that if the mth square or the 1st square is not covered, then the min is 0. Otherwise the min is the minimum segments covering the 1st or mth square. The max is the amount of segments currently considered. Code

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

    No need for segment tree or priority queue. Assume that in the optimal covering, the min point is left of the max point. Then we might as well take the min point to be as left as possible, or index 1, because there is no reason to add segments left of the min point. Therefore, we just use all the segments that don't cover index 1 and do an inverse prefix sum to find the max. Same argument for the min point is right of the max point. Take the max of both and that is your answer.

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

How to solve problem D?

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

    Use the principle of inclusion-exclusion on gcd. This can be done using Mobius function. Time complexity will be O(nlog^2n) I think.

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

    You can count "bad pairs" instead of "good pairs".

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

pE too hard, can someone help me :(( thanks

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

I found $$$D$$$ so much easier for $$$2500$$$ points. If $$$a_k$$$ divides $$$a_i$$$ and $$$a_j$$$, this means it must divide $$$gcd(a_i,a_j)$$$. So, iterate over $$$gcd(a_i,a_j)$$$, Let $$$gcd(a_i,a_j) = m$$$, find $$$num[m]$$$, denoting number of pairs having $$$gcd = m$$$, can be found easily using recurrence $$$num[m] = cnt[m]\cdot(cnt[m]-1)/2 - \displaystyle \sum_{r=2}^{\lfloor{n/m}\rfloor} num[r \cdot m]$$$, where $$$cnt[m]$$$ is the number of indices $$$j$$$ such that $$$a_j$$$ is a multiple of $$$m$$$ in $$$O(n \cdot logn)$$$.

Now, after fixing $$$m$$$, we just need to check if some index $$$k$$$ exists such that $$$m$$$ is a multiple of $$$a_k$$$ or not. This can also be checked easily.

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

WA on test #3,Would someone like to give me the hack data?

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

pE too hard :(( can someone help me, thanks

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

Problem B: https://ideone.com/GV1ZXe why wrong answer on pretest (4) ?

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

How to solve B? Spent lot of time but couldn't think of correct approach. Any hint?

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

    check for total number of 0 and ones in the string for testcase keep a vector to keep the position of one and zeros and use those index to calculate your swapping

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

      Thanks for the reply, I read you comment and even looked at your code, I simply cannot wrap my head around this. I took a similar approach during contest, could you tell me where I went wrong? 229186836

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

        I looked at your code but I am very sorry that I cant debug it, as you may see in my profile that I am not a high-rated coder, and theres some thing in your code like forn, fat(n) that I cant understand. Better if you can watch the editorial after the round is declared finished officialy. Goodluck :-)

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

pE too hard :((( can someone help me, thanks

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

C was very similar to this problem: link

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

is there a non brute force solution for A if k>10 ?

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

I am a beginner but problems A and B were very interesting. Enjoyed solving it

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

Couldnt debug C in time I just need 5 more minute :((

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

Made a screencast for this round: link. Very unedited and just made on a whim.

Got A-D and was almost done implementing E. Probably would've got E if I didn't spend so much time explaining stuff. Lmk any suggestions.

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

I a beginner find it really tough, I cant even solve C, and on B cant get my head around failing to pass the contest 4, but really really enjoy it, challenging myself to make better

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

Thanks guys for the contest!

Now let's get ready to continue with Codeforces Round #905!

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

Can anyone please show me why my code goes wrong

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

Very trash Problem E with 0 thought but +inf boring implementation.

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

I feel like such a loser for trying to debug 229180556 for an hour!!!

I was using 32 bit int instead of 64 bit long long to count the num of operations.

I've made the same mistake couple of times in just this year. I think I should give up on cp.

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

trash contest. The passage is poorly written and difficult to understand, with many omissions.

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

Ratings updated preliminary, it will be recalculated after removing the cheaters.

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

Is it rated?

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

so i recently got a notification that ive been caught for plagiarism, I am absolutely shattered after seeing it. I am assure you that i wouldnt use cheap tricks to increase my ratings, to prove that i had a common source published before the contest

int findClosestRecursive(vector arr, int left, int right, int target) { // base case: when there is only one element in the array if (left == right) { return arr[left]; }

// calculate the middle index
int mid = (left + right) / 2;

// recursively search the left half of the array
int leftClosest = findClosestRecursive(arr, left, mid, target);

// recursively search the right half of the array
int rightClosest = findClosestRecursive(arr, mid + 1, right, target);

// compare the absolute differences of the closest elements in the left and right halves
if (abs(leftClosest - target) <= abs(rightClosest - target)) {
    return leftClosest;
}
else {
    return rightClosest;
}

} this part was taken from a popular coding website geek for geeks i never knew this would be such a problem

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

It was a nice round! Congrats to all participants!