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

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

Hello, Codeforces!

ognjentesic, wxhtzdy, OAleksa, AndrewPav, Acanikolic73 and I are glad to invite you to the Codeforces Round 900 (Div. 3).

It starts on Sep/26/2023 17:35 (Moscow time)

You will be given 7 problems and 2 hours and 15 minutes to solve them.

Note that the penalty for the wrong submission in this round is 10 minutes.

Also note that there will be a 12 hour open hacking phase after the round.

Remember, that only the trusted participants of the third division will be included in the official standings table. As it is written by link, this is a compulsory 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, the round will be rated for you.

Problems have been created and prepared by AlphaMale06, ognjentesic, wxhtzdy, OAleksa, AndrewPav, Acanikolic73, and Vladosiya.

We would also to thank:

  1. Vladosiya for the amazing coordination and help with preparing a balanced problemset, and for giving us the opportunity to create a Div. 3 round.
  2. MikeMirzayanov for the amazing Polygon and Codeforces platforms.
  3. JovanB, abc864197532, sevlll777 for red testing
  4. NemanjaSo2005, n0sk1ll, allllekssssa, Alexdat2000, misorin, Hyperbolic for yellow testing
  5. DAleksa, ljuba, alex.kudryashov for purple testing
  6. MihailoT, SashaT9, BULLMCHOW, Chrisedyong, --tofu-- for blue testing
  7. Andrijanikolic73, Mihajlo18, UrosNedic, Klaus26, Escaquejant, mxon, max0n for cyan testing
  8. Budimmm for gray testing

Also a very special thanks to the most dedicated tester I have ever seen, NemanjaSo2005.

I wish you luck, and hope you like the problems and learn from them.

Update: Editorial is out.

Congratulations to the winners:

Unofficial:

  1. jiangly

  2. SSerxhs

  3. BucketPotato

  4. neal

  5. risujiroh

Official:

  1. hackerjohn

  2. wahb

  3. kutcoder

  4. Sxy_Limit

  5. not_rainboy

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

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

As a coordinator, it was fun to work on the contest in English for the first time!

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

    As a problem setter, I'm proud to have made the first (mostly) Serbian Div. 3 round :)

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

Best of Luck Guys . Surely this would be fun .

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

Serbian div 3, orz!

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

"Throughout heaven and earth I alone am the honored one"

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

is it rated?

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

As an author i didn’t make any tasks.

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

As a tester, I hope you to enjoy the contest and read all the problems. Good luck!

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

As a tester, problems are well balanced and really interesting. Hope you will enjoy solving them and get positive delta!

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

    I will be taking part after reading this statement and having faith in your words :). I don't have any rating hopes as I am more interested in enjoying the round :).

    Will give my review after the contest !!

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

      Good luck!

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

      As I said I will give my review and it is as follows — I liked the problem set , problem D and E should have been swapped then it will be balanced in correct order. Unfortunately I was not able to debug my code for D but I am happy to take part in today contest . Good job to team.

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

Zoves u kasne sate

trazis opijate

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

As a tester I can confirm that NemanjaSo2005 is a tester any author would wish to have. orz.

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

Happy 9th centennial! 100 to millennium!

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

100% SERBIAN BESTEST ROUND!!! SERBIA!!!

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

As a special tester, the problems are good and test data should also be good!

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

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

As a tester, the problems were interesting. I hope all of you enjoy this round.

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

As a tester, I recommend you to read all the problems.

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

Sorry but shouldn't the 900th contest be rated for whole community. I think 901st and this round should be swapped.

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

As a tester, I hope you to enjoy this round, because the problems are interesting and balanced. Good luck!

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

As a late one tester I wish you all good luck!

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

Screwed up the edu round, hopefully this will make up for it!

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

900! damn i feel old

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

2h and 15 mins Is Little time for 7 problems

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

900! Sounds good :)

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

This will be my first official Div.3 contest in 5 months

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

ًWish i get green

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

will there be 12 hour hacking phase round??

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

Round #900 hope to be special for me <3.

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

Cool

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

Do we get 10minutes less if we submit a wrong submission??

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

Hope i can color upgrade ヾ(⭐▽゚)ノ

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

    Me too.. missed by 12 pts last round:(

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

      how do some coders start their journey from 1400 rating? how ?? you are one of them, i'd like you to answer

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

        The codeforces ELO was initialized to 1500 at that times (2018 prob go search yourself idc).

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

        Codeforces rating actually starts from 1500, but a few years ago they made some adjustments so a fake rating is shown for the first few rounds (e.g. your rating is 1400, but 500 is shown). The adjustment becomes less and less, and after like 5? rounds it disappears.

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

    good luck
    I also hope to become at least green

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

Round 900......Seems GOOD

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

900 sounds good. Hope the color change occurs in this contest.

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

Just a comment to get some contribution:)

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

All the best to everyone...

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

I hope the questions are good because this is the div number three I joined.

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

first div3 as out of competition :)

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

    Hopefully I also get to this point someday ^⁠_⁠^

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

Finally an Alpha Male Round :D

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

Can anybody explain what 10 min of penalty means

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

    As you take more and more time to get to the answer, Points get deducted

    For example a guy who solved a problem in 10 minutes would get better rank than guy who solved at 20 mins(Assuming both solved it correctly in the first submission itself)

    But if the 10 mins guy made an incorrect submission before his accepted answer, 10 minutes worth points will be deducted from that problem's points, So in this particular case both 10 and 20 minutes guy will get same points even tho 10 min giy solved it earlier

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

    In Codeforces, you usually lose 0.4% of the task's points for every minute between contest start and submission time, plus 50 points for every failed attempt, the penalty caps out at 70%. Here, the failed attempt penalty is 4% of the total points rather than flat 50 points.

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

      He asked about exICPC penalty rules. Not Codeforces rules.

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

        You're right, I forgot ICPC rules are used for Div3+ rounds (for those who don't know — there's no points, first sort key is total problems solved, second key is the sum of deltas of submission time and contest start + 20 minutes per failed attempt, except here it's 10 minutes instead).

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

Best of luck everyone :D

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

If I couldn't start with the div on time and perhaps joined mid-contest before it ends, will it be rated for me? and can I even join?

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

    Yes, it will be rated for you if you register earlier. But it is not a good decision to attend a contest at the end moment. Every second matters.

    If you are late anyhow, you can give a virtual contest later.

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

I hope there will be a lot of problems on MEX

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

do not have a point of 1900 or higher in the rating.

Shouldn't it be $$$1600$$$?

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

As we all know, div3 is more difficult than div2

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

Why always in queue :(

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

A B C E easy. D crazy hard.

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

Nice.

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

    I think u should just stop founding problems in others and focus on getting better. U are responsible for every problem in ur life bro :)

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

    just use treap)

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

I really liked your ordering of D and E.

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

QueryForces!

»
8 месяцев назад, # |
Rev. 2   Проголосовать: нравится +6 Проголосовать: не нравится
I love number theory too. Thanks for this problem ^_^
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    could you please explain your reasoning behind F? The only one that came to mind was counting divisors in N^1/3 but couldn't proceed from there?

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

        Thank you for the reply. I get it now since the gcd(a,n)==1, if I may ask the method of counting diviosrs is the same as this [N^1/3] or is there an easier way (https://codeforces.com/blog/entry/22317)

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

          factor the number given in the input and just maintain stuff on a map

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

    Answer is "yes" when n is divisible by d(n).
    Reason:
    lets say if we prime factorize $$$n$$$ then we get: $$$p_1^{a_1}*p_2^{a_2}*p_3^{a_3}*...*p_k^{a_k}$$$
    so $$$d(n) = (a_1+1)*(a_2+1)*(a_3+1)*...*(a_k+1)$$$
    let $$$x = \frac{n}{d(n)}$$$. so we need to multiply $$$d(n)$$$ with $$$x$$$.
    now we can just multiply $$$n$$$ with $$$a = p^{x-1}$$$ where $$$p$$$ is a prime number not contained in $$$n$$$. Thus $$$d(n*a)$$$ will be $$$d(n)*x$$$

    ps: I replied to my own comment by mistake lol

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

CF was lagging as hell today!!!

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

Problem B solution:

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

Do we really need to know splay tree to solve a div3D? or there is easier solution.

Btw, problem is same as: https://www.hackerrank.com/contests/w7/challenges/helix/problem

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

    No...

    It's just counting the number of reversals that cover each index (because the reversals are symmetric wrt the segments, the order doesn't matter), so it can be done with a "sweep line" sort of thing (idk if it's technically a sweep line).

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

    There is a simpler solution.

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

    Even easier can be done with Treap. Implementation is very simple, so you might as well learn it if you haven't already. Here is my 30-line template, if somebody wants it:

    Spoiler

    Practice Problems:

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

Cool round! D,E,F are good (even i solved D&E with segment tree lmao)

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

I believe this is not the intended solution, but we can solve D using Splay(or other BST).

This trick is a well-known template on a Chinese OJ called Luogu. There are also similar problems on many other OJs.

We can maintain the reverse operation in $$$\log n$$$ time. So just copying one template code and simulating the requested operation is enough to get AC.

__gnu_cxx::rope also offers this functionality. However, the 1s TL is too stringent, causing it get TLE due to large constant factor.

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

    Of course it's not the intended solution.

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

Wrong answer on test 7 in problem F when there was only 2 minutes left :((

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

I got TLE in problem D on test 10 :((((((

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

I have solved problem E using sparse table and binary search, but it feels like an overkill. Is there an "easier" solution?

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

Please help how to decrease TC in my code thanks :)

Problem E

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

    The time complexity of your code is O(n*q) which will be around 10^10 operations. This will definitely not pass. I did this problem using square root decomposition but I am sure their is a much simpler solution.

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

can someone tell me why am i getting TLE submission . terrible div 3 BTW

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

    Don't use memset, because you will get unnecessary reset when the number of test case is high. Just use for loop to reset the value of "pre" array instead.

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

    It's because you're using memset in each test case which resets the whole array with size $$$N$$$ not size $$$n$$$.

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

      انا هقتل نفسي بجد. هنقص عشان الغلطة الهبلة دي :)

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

        اديك اتعلمتها بالطريقة الصعبة مش هتنساها تاني بعد كده

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

Is it really div.3

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

Problem G seems cool. Is it use LCA + Binary Lifting + Ternary Search the Answer?

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

    It is LCA + binary lifting. I don't see how ternary search could be applied, though.

    My solution may or may not be wrong (feel free to hack because I feel like it's probably wrong and/or too slow and/or too memory inefficient) but what I did was to sweep line on the first/last occurrences of each bit. Implementation requires binary lifting as you said.

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

      From what I observe (still not sure) for a path of $$$p_1, p_2, ..., p_k$$$ I notice that the results forms a parabolic function and we need to pick an optimal $$$i$$$ so that the result is maximum

      But I'm still not sure about it tho

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

        ternary search does not work because: 1. too slow (log^3) 2. wrong because the function of the answer is not not strictly increasing

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

        We can unroll the path into an array and create segments for each bit, which range from the first occurrence of that bit to the last occurrence. The problem is then reduced (with some extra details) to finding a point covered by the maximum number of segments. AFAIK, ternary search doesn't work here.

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

    LCA + binary lifting don't really seem like a Div. 3 approach, do they?

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

    are you sure ternary search would work? I think binary searching for 30 places. where bit count of left side is exactly i (i from 1 to 30).

    can you please explain how would you do ternary search??

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

      Nah I'm still not sure. Just a hunch. What about yours?

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

        i think we can binary search 30 times like this ->

        for each i from (0<=i<=30) we can search binary search for first index j (vertex) from left where OR from first vertex to j vertex has bitcount of i then current value = bitcount(0 to j) + bitcount(j+1 to last). this way left and right will be divided 30 times, then max over all 30 values.

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

does G have a better solution than $$$O(q\cdot log^{2}n\cdot log(max A_i))$$$?

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

problem B was required some focus and analyze the trick to solve the problem in O(N) time complexity

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

Nice Tech Stack , Goes down whilst a contest is going on!!

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

Pretty sure E can be done in $$$ O(q * log ^ 2 n)$$$ . Just had not enough time to accomplish it.

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

I hope i can reach LGM after sys test

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

How to pass E so fast? Right! use ACL! 225318799

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

If someone prefers video explanations or interested in knowing how to think in a live contest or reach to a particular solution.
Here is my live screencast of solving problems [A -> E] (with detailed commentary in Hindi language).

PS: Don't judge me by my current rating :(

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

Can someone explain why E cant be done with for loop iterating over array and performing & with every array element from l to r and checking if it is smaller that k. When I did this all and operations over array gave the first element... what am I missing?

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

    it will give u a tle ,u need to find f(l,r) in more efficient way ig otherwise time complexity will exceed o(q)

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

A good contest QueryForces :)

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

Python is pretty slow for E (drawbacks of using python I guess...):

https://codeforces.com/contest/1878/submission/225408163 This submission TLEs

However when I change bits to 31 instead of 32, it passes:

https://codeforces.com/contest/1878/submission/225409398

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

I solved F successfully after 2hrs + 5min but didn't submit as i thought round was of typical 2hr duration.Clown moment for me.

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

someone tell how to reverse the string from a to b in o(n) time when q queries are given .it is easy if q queries are of the form i to n-1-i but here its i to j ig and its not symetric

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

    It is symmetric for each interval separately, because they are disjoint

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

      u are saying that i need to calculate no. of reversals for eacj index and if its even leave it as it is and if its odd take that character to n-1-i th position?

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

        No, but you can basically treat each l, r as a separate test case and then solve a much easier problem

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

          what do u mean by l,r?those are arrays in the question...

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

            Yeah, you can basically divide the string into substrings from $$$l_i$$$ to $$$r_i$$$ and solve a easier problem for all $$$i$$$

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

What will be the efficient time complexity for the problem D?

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

I had fun today. Thanks for the Contest. Hope we will get more of these kind of contest..

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

StructureForces

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

D and E were extremely cool problems. First time getting to use segment trees in an actual contest :)

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

worst contest i have ever seen in my life ... the level was suddenly increased .... a request to mike that do not allow people like them to make contests

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

Dichotomy combined with segment tree, what a nice problem E!

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

The solution for E was available on geeksforgeeks (pre-written code).Tho it's not a complete solution( u need to apply binary search for answer) major part remains same. Here is the link : https://www.geeksforgeeks.org/queries-for-bitwise-and-in-the-index-range-l-r-of-the-given-array/ Since it's a pre-written code ig cf will consider this before plagiarism check.

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

Funny Solution for B

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

Too many data structure problems can be solved by using template, and the questions are so long that the reading experience is poor. May D is too difficult for Div.3.

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

My B's solution is completely random, I just picked three primes and created the array, checked for some random N <= 100 then submitted. Can someone try hacking it? Btw, overall nice round! Good problem set, except D, which was googlable.

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

https://codeforces.com/contest/1878/submission/225409196 WHY THIS SOLUTION IS GIVING TLE ON 10TH TEST CASE?

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

Had got the logic for question D. messed up by using lower bound instead of upperbound. Got AC on D after the contest

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

    Something similar happened to me. I was using the lowerbound on the 'l' array and therefore there were some edge cases on which the solution was not working and I got WA 3 times. Right after the contest I submitted it using lower bound on the 'r' array and it got accepted. I wasted a lot of time on this.

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

Superb contest. Educational and fun to solve

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

In problem D, I just wrote brute force, I was not able to handle time complexity. Can anyone help me to reduce the time complexity of this program?

void solve()
{
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<ll> l(k), r(k);
    for (ll i = 0; i < k; i++)
        cin >> l[i];
    for (ll i = 0; i < k; i++)
        cin >> r[i];
    ll q;
    cin >> q;
    vector<ll> x(q);
    for (ll i = 0; i < q; i++)
        cin >> x[i];
 
    for (ll i = 0; i < q; i++)
    {
        ll xx = x[i];
        ll a, b;
        for (ll j = 0; j < k; j++)
        {
            if (l[j] <= xx && xx <= r[j])
            {
                a = min(xx, r[j] + l[j] - xx);
                b = max(xx, r[j] + l[j] - xx);
                break;
            }
        }
        reverse(s.begin() + a - 1, s.begin() + b);
    }
    cout << s << "\n";
}

**Submission Link**

https://codeforces.com/contest/1878/submission/225389151

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

    There are $$$q$$$ updates, each one of which will reverse a string of length $$$n$$$ (in the worst case). Reversal of a string of length $$$n$$$ if $$$O(n)$$$ and thus, your code is $$$O(nq)$$$.

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

      Yes, I understood you. But I cannot reduce it. Can you help me to reduce it?

      or if possible you can edit my code.

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

Although I wrote poorly in this round, I know it is my own problem, and I hope I can learn from it and strive for a higher score and ranking in the next round

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

Why are O(n) solutions to C getting hacked? Isn't it guaranteed that the sum of n <= 2*10^5. If you didn't want O(n) why don't you just increase n?

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

Great contest hope to become expert after it

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

First time using Square root decomposition in a contest (for E). Took a lot of time to debug it but got AC!

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

Learning From The Contest: A C++ map may return a garbage value for an entry that is not present instead of 0. Costed me an AC on F(was pretty simple acc to me. D >>> F ) :(

WA bec didn't check if the entry is not there in the map 225417281

AC just after adding a check 225413613

However it is not the intended behavior, can anyone confirm?

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

    D isn't harder than F, you can divide all intervals and treat them like separate test cases basically so it becomes much easier

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

      Ikr. The substring reversal thing was kind of a good observation I would say to apply in the merged intervals to avoid repetitions and it got framed into a really nice problem where pairs of positions were just getting swapped.

      It may be possible but personal opinion I found F pretty standard. Like we need to do what exactly is told. (And regarding the division which is to be done by Prime Factorisation is also a pretty standard technique)

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

        Yeah, but F is kind of weird in a sense where if you know basic number theory you will probably solve it and if you don't you are doomed

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

    I don't know, but I have always assumed that map and unordered_map always return the default value for int(which is 0) when the key is not present, and I have never encountered this issue before, which is quite strange. In fact, my solution to F relies on this behaviour.

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

    I agree D>>F

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

    Accessing mpp[x] where x isn't in the map will return 0, but it also inserts x into the map so the other check (mpp.count(dn)) would then return true for values that shouldn't be in the map.

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

definitely didn't create the same segment tree Q times on E :(

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

Does this relation always hold true? a&b=a+b-(a OR b) physics0523

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

    (a XOR b) + 2*(a & b) = a+b is famous. Try to proove it from this.

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

      actually I saw somewhere on the internet that (a XOR b)=(a OR b)- (a AND b) . So, on combining both equations ( I mean the other is which you have told) I got the equation which i have asked in first comment.

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

can we prove in C that we can make every number b/w (k*k+1)/2 and (n + n — k + 1)/2 ?

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

Too bad, my C incorrectly used O(k) algorithm, which should have caused TLE, in fact my friend made a mistake once for this reason and corrected it, but my commit somehow passed the test case and got hacked:(

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

Discovered logic of E without Binary Search might be useful

225421215

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

What is the purpose of writing such line in Problem C?

Note that the sum of n over all test cases may exceed 2⋅105

I thought the convention is not to write this statement if it's true. Maybe I should disable the Dark mode to avoid missing the Bold text.

Anyway, Thanks for the contest.

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

    It's because people often don't read that and assume that it's true, that's why it's bolded.

    We also allowed that because some people don't know the formula for the sum of first $$$n$$$ numbers, and we allowed it so they can precalc it.

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

Silly of me to just come up with a solution for "C" using pick and not pick recursion. I need to follow Constraints. Can anyone explain the "C" here?

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

    It can be proven that the answer is YES if $$$x$$$ is between the minimum and maximum possible sum.

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

    you can make any number between range [k*(k + 1)/2, (n + n — k + 1)*k/2]

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

Do we get any points for successful hacks ?

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

Authors, where is systests for sum of n exceed 2 * 1e5 in task C? I made a stupid mistake because of speedforces and fast-reading of easy task. Why didnt you cover this obvious case? Please cover such tests in the next rounds.

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

I tried to hack O(n) solutions with more than 900ms runtime on Problem C but getting more unsuccessful hacks..

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

    the compiler strongly optimizes problems such as C. There are O(k) solutions which passes also a maximal stress test.

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

Solutions were leaked during the contest and many people cheated. Requesting CF to filter them out and update the ranking accordingly.

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

Holeee newbies in comments using stuff like treaps, splay trees and idk what not and complaining. Like do people not think that perhaps this is too much? Why would you even learn all that at this level kek?

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

mala ga lomi

sija mi ko kristal na dejtoni

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

Video Editorial For problem A to F.

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

I think the questions belong to Div2

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

I can see how D would be done with trees. How would D be done without trees? Would appreciate a general explanation of the overall strategy.

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

    1) we observe that the k segments are independent of each other so we can solve for each segment and then append them to get the full answer

    2) we observe that to solve for one segment ,a range(a,b) in a query is always in the middle of that segment (because it is either from x to r-(x- l) or from l+(r-x) to x ) i.e we can say that each element is either mirrored about the center of the segment or not.

    Now to solve this we can use Difference array to easily perform range updates of +1 to each element in range(a,b) (indicating that letter getting mirrored) .At the end we get the resulting array and for each A[i] that is odd we mirror that letter.

    here is my python solution

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

Solved problem 1878D - Безумные развороты during the contest in time $$$O\left(n \cdot q\right)$$$ by performing all operations by its definition here 225330103 and here 225334036 in 889 ms

UPD Here is non-hacked $$$O(n\cdot q)$$$ submission 225577099

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

    Petition to ban pragmas

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

      Petition to all problemsetters to make sure unintended optimized $$$O(n^2)$$$ doesn't pass. Although this can be difficult if slower languages also need to pass.

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

    Hacked!
    If the TL was 2s, I think it will pass the systest...

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

      Thanks!

      Here is a small trick: I solved in $$$O(n \cdot q)$$$, then solved problem E, then solved problem F, then re-solved problem D in right asymptotic.

      In ICPC-like format the first non-hacked solution is used by the system for determining the score. In codeforces-like format the last solution is used.

      So, I still have my +1 score for problem D.

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

      Do you want to hack mine $$$O(n^2)$$$ solution as well (it just uses Rust's regular reverse method of the slice)? 225437815

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

      About problem C I use loop to computa the series, i think it can't TL, but how can you hack me, please tell me why, thank you

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

Can someone share to me segment tree solution for E?

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

I solved 1 problem! This is the first time!

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

https://codeforces.com/contest/1878/submission/225301449

is this solution able to pass or get hacked ?

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

    I tried to hack with the worst case possible for this submission, it said "Unsuccessful hacking attempt"

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

I was confused on the E problem, why when I use &pref to pass it to the function, the code return TLE on test2, but use the global pref it passed? I means why &pref is soooo time consuming?

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

    vector<vector<int>> pref(N, vector<int>(30, 0));

    I think because you initialize this line of code inside while (t--), with t can be max 1e4 and const int N = 200003; then it will be t * N * 30 (about 6e10).

    You can replace N with n and submit again.

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

I've just upsolved problem E with Segment Tree and binary search, some may say it's unnecessary or overkill but I'm happy to realize and apply them.

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

My rating is just 600 but this competition wasn't rated for me. Did I do something wrong?

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

Hello! My rating is less than 1600, but the round wasn't rated for me. Why?

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

When rating is uploaded

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

Why i dont in winners of unofficial or official if i had taken 5 place in div3 overall?

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

why my O(n) solution is getting TLE on main Test 24

225340052

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

I am pupil thanks to this round

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

SpeedForces ABCE?

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

The site showed me +58 and gave me +15 . Whyyy? . And still it is not changed.

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

G, so hard

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

    It's probably easier than an average div.3 G, the only hard thing is the topics it requires

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

orz not_rainboy skip spec

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

tough div 3

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

Wonderful G! I like it!

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

When will the contest ends. I mean is the contest live do i get rated if I submit it today

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

I think it's fun and nice.And it makes me a pupil

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

Unlucky me not mentioned in the blog as a winner because I am the 6th place officially : ). That last round was the best performance of me so far I am so proud of it. Thanks for the good round!

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

the question 1 of this contest is wrongly defined