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

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

Γεια σου (Hello), Codeforces once again!

Adam_GS and I are glad to invite you to participate in Codeforces Round #912 (Div. 2) which will take place on Nov/30/2023 19:35 (Moscow time). Note the unusual start time of the round. As usual, this round will be rated for participants with rating lower than 2100.

Problems were created and prepared by Adam_GS and me. We tried to make them interesting, with short and clear statements. We hope that you will enjoy them!

I would like to thank:

  • ScarletS for amazing coordination of this round.
  • Adam_GS for joining as an author after testing the contest.

You will be given $$$6$$$ problems (and one subtask) and $$$2$$$ hours and $$$15$$$ minutes to solve them.

The score distribution will also be announced shortly.

Good luck and have fun!

UPD1:

Score Distribution: $$$500-1000-1500-(1500-2500)-2250-3500$$$

UPD2:

Editorial

UPD3:

Congratulations to the winners:

Div2:

  1. DoIodu123

  2. 69JohnMouse69

  3. transfeft

  4. vflower

  5. Top2Greece

Div1 + 2:

  1. Um_nik

  2. ecnerwala

  3. Ormlis

  4. tourist

  5. noimi

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

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

As a tester,the problemset is superb!Hope you enjoy it :)

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

    hammaga omad tilayman!

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

    Hope i will became pupil after this contest...!

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

      i hoped too

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

        why u use hoped, not hope?(I just asked politely, because my English is not very good, and if I am offended, I am really sorry)

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

          haha i used the past form because i posted after the contest was over and it didn't go well for me .

          I somehow managed to get the delta equal to zero :)

          so u know how worse it was going for me :/

          any you didn't offend me . So ,no need for sorry :)

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

As a tester , I wound recommend to read as many problems as you can

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

Nice to see a round from a person(Theo830) who was sitting to my left on IOI2023 :) And a Person(Adam_GS) Against whom I played Table tennis :))

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

As a tester i can say that the problems are fun and interesting with a Cypriot twist ;)

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

Good luck everyone ^_^

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

Tomorrow I will understand how bad doing contest late(like Chinese).

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

I might give this round and solve D1-D2

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

According to score distribution, D2 >> F .

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

As a tester, I wish you all good luck!

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

As a tester Cypriot, I hope that statements are short and pretests are strong, making our tiny island proud!

ps. I will be competing so if I lose rating Theo830 pls make it unrated

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

As a tester, I confirm the problems are interesting... hope y'all have a positive delta!

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

    Div.2- Fs are usually easily solved by most IGMs in contest, furthermore, they are usually GM level. I hope that such a group, to whom Earth puts all their faith in to solve any problem, are not only lowly GMs, so this should be factually wrong

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

    The fact that there is no account with username avengers makes me sad.

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

My sleep and the contest are at crossroads today. I will choose the contest.

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

GLHF

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

Guess — D1,D2 can be dynamic programming with varying constraints.

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

As a tester

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

As a tester, certain problems are, for the lack of a better word, based.

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

As a human , aqua > cola.

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

orz

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

At least i can blame sleep deprivation if i mess this round up

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

The start time is 00:35 for me, so I can sleep well

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

The timing of this round is awful for Chinese students, I hope I won't be late for class the next day

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

contest >> sleep >> university exam

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

    The next upcoming contest also same for me..!

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

    Agreed! Somehow, my love for contests grows twofold during exams. With an exam tomorrow, this contest will surely be my doom, but a beautiful doom nevertheless..

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

    literally me rn. I've got an exam tomorrow and 0 motivation to study

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

    contest >> sleep >> The first class at 8:00(+8)

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

The first, I will be giving a contest at 10:05pm(India)

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

Hi

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

Hoping to become a Pupil after today's contest

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

As a farmer, I mean tester.

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

I hope I don't get late for tomorrow's class. Good Night!

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

W cyprus round

orang soon?

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

Nice problems. I got 5 wrong answers and wasted 1 hr for a simple integer overflow bug in D, could've been a good contest for me.

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

    How to counter it?

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

      There are a couple of ways:

      • Use 128 bit integers if you can, though I wouldn't recommend that as a great practice as such.

      • Consider the given problem: I counted the "sum of required moves" and compared that to the number of allowed moves. Here, individual elements could take upto ~1e18 moves for large bits and considering that there are ~1e5 numbers, the sum could be as large as ~1e23. One way to avoid the overflow is to stop adding to the "required" variable once it exceeds the "allowed (k)" variable, just add an if statement (or alternatively, use min(required, k + 1)).

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

      Keep a backup of the remaining k and do the operations for each bit in an online fashion, i.e, don't wait to accmulate need for each element and then check if $$$k > need$$$. Instead, keep on subtracting from $$$k$$$, and track whether the operation was a success or not. If it wasn't, overwrite it with the old $$$k$$$.

      It is essentially the same as finding a missing number from the set $$$1, 2, 3, \times n$$$. If you do n*(n + 1)/2 - existing_sum, you face overflow issues, but if you do it in an online fashion, where you run a loop, and in each iteration, add $$$i$$$ but subtract $$$a[i]$$$, it'd work.

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

        Since all numbers start < 2^20, can't we just check if we have enough operations to get all numbers to 2^20? If so, isn't the strategy to split the remaining operations equally among the elements, i.e. the max would be (2^20 + (remaining ops)//n)? I thought there should be no need to check "required moves" for bit spots above 20, but maybe I'm missing something.

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

          Consider a single element, say, 1. It is true that it starts with one bit, but if $$$k = 10^{18}$$$, then new bits would appear.

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

            Sure, but this doesn't affect what I'm trying to say. Let x = n*(2^20) — sum(a_i), the number of operations needed to get all elements to 2^20. If the query k is >=x, isn't the correct answer equal to 2^20 + ((k-x)//n)?

            I'm not suggesting this gives any information for how to solve the problem for k<x, only that it seems unnecessary to make any precomputation about how many operations are necessary to set the mth bit in a_i for m>20.

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

    Can relate so hard to this ;_; I faced the same issue, assuming you're talking about the "long long overflow".

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

$$$E$$$ was easy to solve, but hard to implement. Thanks for cool tasks!

UPD. After checking some submissions, i can say that i am just noob and E wasn't hard to implement:)

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

balanced contest with good problems

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

What the fuck is a pretest number 15 anyway

Man I had such high hopes for D2, unlucky

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

    What was your approach? It's clear that we keep the amount of steps for each i to get all numbers to i-th bit and iterate from the leftmost until we can subtract that amount from k. But then how do you find the remainder bits that also will be part of the answer?

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

    I suspect its the first max constraints test or similar.

    I coded a weird approach without realizing it was actually still $$$O(q \cdot n \cdot \log(10^{18}))$$$ in the worst case and it reaches pretest 15 before failing.

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

      What is weird, even if it is some maxtest, my verdict is not TL

      Unless I have overflow somewhere in my code (unlikely)

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

What was the approach for C?

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

    i run from i=n-1 to 0 and holding the cost required if i want to combine element i and i-1 (combine to same subarray)

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

    i solved it using suffix array

    if the suffix sum is negative then it is better to merge it with previous else keep it in a new subarray

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

Nice E!

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

Solved A,B and C. But I feels C is slightly easier than B

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

Problem C and Problem D in CF EDU 66 are the same actually, isn't that enough to make this round UNRATED?

Problem D code
Todays Problem C code
  • »
    »
    6 месяцев назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    They are slightly different. One asks for a specific number of sub arrays and the other doesn't.

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

    If you actually read the two problems you'd see that they are different, the problem you linked is bounded with a given integer K for the amount of subarrays, whilst in the problem C from today's contest, we aren't bounded at all.

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

    They aren't the same actually (today's C allows for any number of subarrays, that EDU D requires $$$k$$$ subarrays), but the solution ideas are still almost the same (reduce the problem to sum of suffix sums).

    But no, rounds aren't made unrated because of repeated problems. Only copied problems make rounds unrated. If the problems were similar on accident, the round is kept rated.

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

    Even if they were the same, I don't think the contest would be unrated. In contest 1898, B is a classical problem appeared on other websites and D is an easier version of https://codeforces.com/contest/1513/problem/F. But the contest is still rated.

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

    Stop it. There are more than 20000 problems, for each problem you can find simular. But if you really search every problem, for which reason you participate in contest...

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

Could anyone please explain how to do B and C? TIA

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

    my approach was to do AND of all the elements in each row (expect for the i==j element since it is 0). this gives the ai value (i is the ith row)

    And after that you can check if the answers are right or not by doing ai OR aj for the matrix. If matrix matches then YES, or NO.

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

Come on!! The solution to Problem B was uploaded on Youtube around 40 minutes before the contest ended. That would explain the sudden rise in submissions (700+) on Problem B in the last half hour. Disappointed ://

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

    so I can assume, you've googled it........

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

      I already gave up 1 hour into the contest after solving A. I searched them with the sole purpose of reporting their channels which I did.

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

      Could you pls tell what should be the difficulty level of problem B

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

    Nothing new. This has been happening at almost every other contest. Not much we can do other than improving our speed of problem solving and coding.

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

Not sure about visiting Cyprus after this contest

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

Someone explain B. How do i develop intuition for such adhoc problems ?

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

    i dont know what really adhoc problems look like.but i think b is not.

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

      even if its not, what do i do to solve div2 B in each contest

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

        well it's very easy to see one thing if you go column wise the element on that column remains same i.e a2|a1, a3|a1, ... so on so you can just see the bits that are set in all these elements i.e M21, M31, ... MN1. This gives you a1 similarly do it for a2, ..., an. Then just make another n*n matrix and check if that equals given one if yes print ans else just say no

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

        I think this B was easier than previous B's so you should try to make observations for B as B don't require any algorithm just observation (same for C sometime)

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

Great problems! Keep it going. Would love to see a div1+div2 from you next time!

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

Missed Specialist just for a minor fuckup!!

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

E is a really cool problem, I love how the winning condition is so simple and easy to prove.

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

Any hints for D2?

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

    I tried separately calculating costs to set all bits going from highest to lowest, then calculating the cost to set all lesser bits after I set the i-th bit in all numbers.

    For yet unknown to me reasons, this approach does not work, or maybe I haven't anticipated overflow somewhere in my code.

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

      Yeah, I might have a suspicion why this solution won't work. So when we are searching the first bit that the final answer will contain, we do not consider that some of the numbers have it set to 1. That's why when we calculate the "lesser" bits, we do not actually sure if all the numbers have a suffix of zeros. (cause from some of them we did not subtract anything at all)

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

        Logic of my solution is something like this:

        • If all numbers share same leftmost bit — nothing happens, I look further
        • If only some numbers contain it — I don't touch them at all. Those, that do not contain that bit — I erase the suffix of such numbers (to calculate min cost)

        So, if some bit has come before, I either don't do anything with the number at all, or that bit has to erase any lesser bits anyway

        I couldn't come up with a counter example myself, I don't know if this is the part in my solution that is wrong, but I did have such concerns during the contest (but I chose to believe that my guess is correct)

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

        I've explained it a little bit messy, but hope you've gotten it.

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

      If you change number x at some bit i, then you need to update the cost function for other bits

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

        That's why I have an array costs — initial cost to set bit $$$i$$$ in all numbers, and 2D array post_costs — the cost to set any bit $$$j$$$ that comes after $$$i$$$

        UPD.: nvm, I see how my solution is failing, I can't just calculate costs taking the initial bit that I've set and looking at the costs to set lesser bits.

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

          How are you handling this post_costs, I can't figure out anything except O(nlogA) per query.

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

            I tried doing precalc, but the way I'm calculating the costs later on when answering the queries is not correct.

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

    I had the idea to optimize the D1 solution using a bitwise trie. Same idea, but you traverse the bitwise trie which contains some additional information.

    I didn't manage to implement this, so could anyone say whether this is the right idea?

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

      No. I thought about this idea on the contest and saw, that when we have to go to the left son in our trie(when we calculate the answer), we also have to know all information about all subtrees of the right son. We cannot maintain full information about subtrees of the right son, because it requires some additional memory and time :(

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

Ahhhh....Thursday....watching my favorite anime characters and my rating go down....what can be better?

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

any hint for problem C ?

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

great contest. I'll definitely learn something from this. THANKS :)

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

Can someone help with Div 2 C.

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

what is the idea in problem C?

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

    If you start a new subarray whose left end point is i, then the change in answer would be the suffix sum: suf[i]

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

    If you delete an element at position i, the sum will change as sum -= suff[i,n]. Thus, deletion of one element does not overlap with deletion of other elements and for each element we can find need it delete or not.

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

Where can i find official solutions for this contest ?

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

I solved B but I don't know why it works, hopefully, system test passes :D

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

    may i see your solution?

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

      so I just did AND of every row ( excluding the diagonal element ) and printed that as the answer after checking if it forms the grid

              int ans[] = new int[n];
       
              for (int i = 0; i < n; i++) {
                  int and = (1<<31)-1;
                  for (int j = 0; j < n; j++) {
                      if (i == j) continue;
                      and &= arr[i][j];
                  }
                  ans[i] = and;
              }
      

      after this, I just tried to create another grid ( not explicitly ) and checked if it was the same as the original grid, if NO, I said it is impossible, but I don't know why it is impossible.

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

        ok it passed, I am lucky, hopefully editorial explains it well

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

        oh same solution as me but whats this int and = (1<<31)-1; mean?

        it make you can AND in the first round of loop?

        because i did this

        vector<int> ans(n,-1);
        for(int i = 0; i<n;i++){
            for(int j=0; j<n;j++){
                if(i == j)continue;
                if(ans[i] == -1)
                   ans[i] = M[i][j];
                else
                   ans[i] &= M[i][j];
            }
        }
        

        Im not good at bitmask sry.

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

          They are turning on all bits but leftmost bit (which is the sign bit).

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

          oh so I started with the first member being arr[i][j] .. but it was 0 when i == 0 and j == 0 so I didn't know what first value to choose

          this and value is a binary number with 31 1's in it, which is more than any number so doing AND with it will give back the input number

          why is your whole row not zero for the first row.. because arr[0][0] is 0 so and first row will always be zero in your case.

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

            sorry I'm in a bit of a hurry mb

            this is my B solution here

            but i do from every top and right number of M[i][i] that i just realized top of M[i][i] is the same as left of M[i][i]

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

        Yeah same, I applied same thing and don't have concrete proof of why it works

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

misunderstood problem C summation (len of subarray_i) * sum_i :(

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

got AC in problem C without knowing what exactly I was doing LOL. Maybe it will be hacked

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

If you want to build intuition for problems like today's C. Theofanis' Nightmare, try upsolving 1132F: Clear the String. I was lucky to have upsolved it very recently and the idea instantly clicked :) (I've also added hints for 1132:F if you don't want to read the editorial.

How does intuition from one transfer to the other?

Submission

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

What is the intuition behind Problem B?

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

    It's the fact that $$$0 | x = x$$$ and $$$1 | x = 1$$$ for $$$x \in {0, 1}$$$

    This observation is enough to solve the problem.

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

Amazing round, loved solving the problems!

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

I overcomplicated C to a stupendous degree. Looking at everyone else's submissions, simply going from the back was enough. I instead viewed it as $$$\text{psum}[a_1] + 2(\text{psum}[a_2] - \text{psum}[a_1]) + 3(\text{psum}[a_3] - \text{psum}[a_2]) + \dotsc + k(\text{psum}[a_k] - \text{psum}[a_{k-1}]$$$, then expanded it to yield $$$-(\text{psum}[a_1] + \text{psum}[a_2] + \text{psum}[a_3] + \dotsc + \text{psum}[a_{k-1}]) + k \cdot \text{psum}[n]$$$,

then I iterated over $$$1 \leqslant k \leqslant n$$$ and chose the $$$k-1$$$'th minimum values of the prefix sum in order to minimise $$$\text{psum}[a_1] + \text{psum}[a_2] + \text{psum}[a_3] + \dotsc + \text{psum}[a_{k-1}]) + k \cdot \text{psum}[n]$$$, and summed them.

The way I did this was sort the prefix sum and create ANOTHER prefix sum for that prefix sum. It got pretty damn hectic.

235105543

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

    sameeeee, i even thought of using segment tree to multiply AP to a range lmao, but i knew this wasnt the intended solution

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

    Thank to your explanation. My friends did like you as well but I don't understand until your comment LOL. They used only about 6 minutes, whereas traversing backward cost me 1 hour to come up with

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

D1 using binary search?

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

    yes, but cost function can overflow long long if not careful

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

      can u plz explain your logic

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

        Try greedy from highest set bit to low. If it is possible to make all $$$a_i$$$ have the bit set with no more than $$$k$$$ then do so. Here we binary search the highest bit possible, though a loop may be sufficient. Edit: I don't think it is correct though, you can try reading editorial of this problem.

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

Legit random solution for F or weak systests? (Enjoy to hack)

Add all vertices to the set of answer. Repeat the following sufficient amount of times:

  • Find minimum difference between to vertices in the set
  • Randomly delete one of them, and add all vertices incident to it to the set

https://codeforces.com/contest/1903/submission/235123989

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

    Hacked with a bipartite graph, when there is an edge between two nodes if they have different parity.

    The answer is $$$2$$$ but there is almost no chance to find it.

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

Tried solving D1 using this approach: While iterating from higher order to lower order bits, say you are at bit bit. Then, you check the current bitwise AND for that position. If it's not one, and we can make it 1, we should. So, for every $$$a[i]$$$ which doesn't have the bit position set, we set it. To set it, we look at its bit - 1 bit. If it is set, then we need to add $$$2^{bit - 1}$$$ (i.e, we are borrowing from the neighbor while clearing the neighbor's bit). If the neighbor is not set, the cost has to be $$$2^{bit}$$$.

Can anyone please point out the flaw with this strategy?

Submission

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

    Suppose the bit-2 bit was set, then you need to add $$$2^{bit} - 2^{bit-2}$$$. In general, you need to check all the bits with lower value than the current bit, not just the next one.

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

      Ooof, how did I miss that? Thanks. Fixed Submission

      I guess I got too involved with figuring out the borrowing strategy that I overlooked this simple fact: Each operation only increases the value by 1, so if we want to turn on the $$$i^{th}$$$ bit, then there is only one number that we'll reach first before others, i.e $$$2^i$$$ (pretend the higher order bits are zero). And also, there's just one strategy to go there, because $$$val + cost = 2^i$$$ implies that $$$cost = 2^i - val$$$.

      Since, any number can be represented as $$$\sum 2^{set\_bit\_index}$$$, we can clearly deduce the cost is $$$2^i - \sum 2^{set\_bit\_index}$$$

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

Problem D1: week test case submission case:

1 1
1

0

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

I try to solve D2 with Trie but failed, does this problem solvable with Trie?

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

Am I right in that the only thing that matters in E is $$$(s_x \oplus s_y) \mod 2$$$ and whether there is more ones or zeros among $$$(x_i \oplus y_i) \mod 2$$$? If so, I love the problem, but I hate what it did to my rating haha

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

I got stuck in problem E because my answer is choosing "First" while the testcase says "Second" and I'm trying to figure out what is wrong in my idea while it's all correct.

So I just want to say that the most most stupid thing you can do in a contest as a problem setter is to put a testcase in a problem and say that this is not the optimal solution in the description.

I don't have to read the description cool ... and I don't have to search in all the page for a fool note.

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

TheForces Orz...

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

good contest

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

Great contest and nice problems ! Special thanks for problem E :)

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

You can do divide and conquer on queries in d2

Crucial observation is that if we add to a certain number to make bit B on, every bit below it turns to 0, which means for future steps, the adding calculation is straightforward. I call these numbers "stragglers".

The idea is that for bits > (highest possible bit of MAXAI), either we kill or don't kill all the bits. If we kill all the bits, every number is a straggler, so it becomes easy to calculate. Else, the array stays the same. So no extra memory needed at this step.

For bits <= (highest possible bit of MAXAI), we actually care about the array. If we don't kill all the bits at this step, we store A. If do, we need roughly sz(A)/2 elements in the worst case. At least it seems.

However, notice that although the array A is big, after we kill off the biggest bit, there are only sz(A)/2 possible values. So actually, yes, at each recursive step, we only need sz(A)/2 + sz(A)/2 = sz(A) memory, so after bit <= (highest possible bit of MAXAI) we only need MAXAIlog(MAXAI) memory total.

Queries can be updated naively because the depth of the recursive calls is log(K) and we split it up into disjoint intervals, so each query is only touched log(K) times

This is my thoughts after discussing w/ adamjamil after contest. In contest, I had such a scuffed impl since I sort of handwaved the argument above, leading to a lot of extra constant factors that weren't needed. But here is the final impl, is pretty fast :) submission

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

Looking at my graph I think I'm really a purple coder.

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

Problems were really high quality

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

Can somebody tell me why are samples in E not correct? I lost 20 minutes because of that, it is so stupid. There were few more technicalities that were so dumb. Overall, I liked the problems. Great round, better than last few.

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

    There are samples only for input example :)

    They haven't any relations with correct tactics for the problem.

    My solution goes first in the first testcase of sample)

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

      I get it, but just imagine implementing the solution that works, running it, and getting First, Second as an output, while the sample output is opposite. If both players play optimally, the winner is uniquely determined. I don't see a reason for doing this.

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

        Reason is to don't give any hints to participants.

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

          It could be done by giving a trivial test case. On the other hand, the solution is enough complex that it is very difficult to spot any pattern based on samples only.

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

Some individuals have mentioned encountering integer overflow issues with their D1 and D2. A helpful workaround involves utilizing a long double instead of an int64_t, as long double can manage cases like 1e25 or 1e1000. It's noteworthy that you can still compare a long double with an int64_t, and if the situation permits, the long double value remains equivalent to the int64_t value.

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

Greetings from Greece! The problems were interesting, congratulations.

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

After working through the problems (since I didn't solve any in-contest), here my thoughts:

A: nice easy problem (I misread as exactly K at first, and thought I was going to have to implement something more challenging)

B: a nice problem, perfectly fits the expected difficulty

C: really nice problem, 1 observation about how to rewrite the sum, then easy short code

D1: nice problem D (fairly standard though)

D2: hard for problem D, but a really good problem in my opinion

E: nice interactive problem, observation felt the same difficulty as C to me both E and C basically just involved rewriting some summation *slightly, and then implementing something relatively simple

F: another really nice problem in my opinion, perfect fit for it's difficulty I had trouble setting up the implications in contest, but after seeing some solution and learning a very clean way of doing it --particularly from ecnerwala's solution

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

My favourite problem : E

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

give some good articles for questions in contest along with tutorial

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

Hello, i'm Nurislam and i am using two accounts to participate an contest and i want to both rank up so i am sending the same codes on both accounts, thats why my submitions are ignorred. Please understand me. If you say that this is cheating okay, that won't happen again but don't ignore my submitions for this contest