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

Автор 300iq, 5 лет назад, По-русски

Привет, Codeforces!

Рад пригласить вас на Codeforces Round 562 (Div. 1) и Codeforces Round 562 (Div. 2), которые пройдут в 26.05.2019 18:35 (Московское время). Раунд будет рейтинговым для обоих дивизионов (^人^).

Участникам обоих дивизионов будет предложено пять задач и два часа на их решение.

Задачи были придуманы и подготовлены мной. Спасибо KAN за помощь с раундом, sunset, TLE, Sulfox, isaf27, Lewin, Aleks5d и wrg0ababd за тестирование и обсуждение задач! А также, спасибо MikeMirzayanov за отличные системы Codeforces и Polygon!

Поздравляем победителей!

Div1:

1) DearMargaret

2) OnionPringles

3) Errichto

4) maroonrk

5) Um_nik

Div2:

1) Szoboszlai10

2) lelolas

3) ndmitrovic

4) prick

5) Stardust

Разбор задач

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

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

1

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

How many problems are shared between Div1 and Div2?

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

I wish problem statements are short like this announcement!

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

Why are the links for both divisions duplicated in the attachments section of the annoucement ?

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

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

Можно тоже пообсуждать задачи с вами?):

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

300iq's problems be like:

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

Long time no see!!!

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

Lets have a great contest Guys . Enjoy everyone and best of luck for it

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

300iq is return back with awesome contest :)

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

I hpe the problem statements are as short as the announcement :)

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

Which is Harder Red in Codeforces or Grandmaster in chess?

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

How many problems will be in contest?

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

I like weekend competitions, thank you 300iq

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

Anyone else facing problem in hacking? I get 403 when I try to open code even though I locked.

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

How to solve C? I could easily write O(nm) DP solution, but how to optimize it?

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

    I used binary search from 0 to m for O(nlog(m))

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

      I tried to go for this approach too, but couldn't figure out how to simulate given an answer.

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

        have some int prev = array[0]

        i = the max number of moves a number can increase.

        for every int a, if a > prev, check if it is possible to increase a to prev in i moves. If not, prev = a.

        if a < prev and you cant even get to prev by increasing a i times, return false,

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

      how to check for some M if its possible?

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

        Go from left to right through all the numbers. Attempt to turn the input array into a non-decreasing array. Say when you're at a given number, the biggest value yet has been X. The current number has value Y. You'll be either able to transform that number into X, or increasing the value of that number will be worthless; so if (Y+M)%M > X, the maximum of the array remains unchanged; else, if Y is also < X, then that M isn't valid.

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

    Yeah me too

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

    Use something like a binary search...

    Say we can use k operations to make it non-decreasing. We can obviously do it in k+1. So search for value where it will be impossible to do in lesser steps.

    See this Solution

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

    what about a binary search for the answer?

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

    The way I did it was using binary search because the answer is in [0, M]. Checking if a value is a valid solution means doing a greedy: attempt to turn the input array into a non-decreasing array with a set of operations, lesser than value X. If value X is valid, then you might find another answer lesser than X; otherwise, the answer is surely bigger than X.

    That greedy verification implies going from left to right through all the numbers, and at a given number, you try to approach the maximum of the array as much as possible; that means either not doing anything with the number, or otherwise, you can always set it to that maximum of the array.

    Well, I hope this logic works, still waiting for hacks

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

That moment when I realized problem B can be done by sole bruteforce...
I need better observation tho :D

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

    Which bruteforce?

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

      Every substring of length 9 contains a triple such that $$$x_s = x_{s + k} = x_{s + 2k}$$$. This allows for a brute force solution to pass.

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

        How did you get that?

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

          I couldn't figure out a way to prove it during the contest. So I just wrote a brute force code which checks for every length N string, whether it contains a triple or not. It only took about 10 minutes in total.

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

          It felt like because there are only two characters, avoiding those triples seems pretty hard. If you want to avoid triples, the number of restrictions on the string grows faster than the length of the string. So I wrote a script to verify all cases. Maybe there is a nicer way to prove it, though.

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

    I did that in the end,but how to prove it fits in TL?

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

      I'm not sure about proving, but by generating all possible cases, the longest "shortest pair $$$(l, r)$$$ with fixed $$$l$$$" would never exceed $$$10$$$.

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

Good tasks, thanks)

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

How to solve C? Tried some mo's algorithm, then realized that I forgot it has to be in order.

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

    For each i and bit position b compute the smallest index minReachable(i)(b) >= i such that a(minReachable(i)(b)) has bit b set and minReachable(i)(b) is reachable from i.

    Processing the query: reachable if there exists bit b set in a(y) such that minReachable(x)(b) <= y.

    54686628

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

Congratulations to amnesiac_dusk for becoming red.

I hope so.

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

Was anyone able to hack anyone?

If so, what was the hack

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

A, C and E are cool, B quite standard, D tedious but still not so bad (because it requires some ideas and observations). So the round was nice but WTF is up with those Shi/Fou instead of YES/NO? I had to look back into the statement every time I run my code. This should happen only if problems are translated from a local contest to CF mirror. Don't do it in the future.

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

    I feel the same every time I see TAK/NIE in polish tasks.

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

      At least "NIE" has some resemblance to "NO" (same first letter) so it isn't that bad. Same if it's in some other random language like Nein/Nyet.

      Ofc. using TAK/NIE would still be stupid in a CF round that doesn't come from a local contest.

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

        That comment made me looking up all CF contests your did and surprisingly I haven't found a single TAK/NIE

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

          Maybe I don't take problems from local contests? :D

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

            No, I just've thought you might've changed your opinion in the past (I personally don't see anything bad in TAK/Nie and Fou/Shi) and it would've been amusing to look that up now :)

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

    It's because 300iq is learning Chinese recently.

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

    C is cool and B is standard? Didn't you swap the problems?

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

      I like dynamic programming, but indeed C was standard (still cool for me).

      I got the idea for B in 1 minute that long strings have such triple, after failing to construct a big string that doesn't. Something like this appeared in many problems.

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

    const string yes =..., no =...;

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

    Oh, i thought that it won't be a problem..

    I'm sorry if it spoiled the fun of the contest for you :(

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

      It doesn't ruin on the contest, but it's something very easy to avoid for other setters, and I hope my comment will prevent any future occurrence of something like this.

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

    Btw, why is D tedious? The intended solution has a very short implementation in ~100 short lines.

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

      Ok, I change my mind. My implementation is much longer because I did more (unnecessary) things.

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

Hi! Can someone please tell me why greedy approach does not work for div2 C? (C. Increasing by Modulo). This is the approach I am talking about: for all arr[i] where i>1,<=n if(arr[i]<arr[i-1]) either increase arr[i] or decrease arr[i-1](increase to m, then to arr[i-2]). store number of operations needed for each arr[i], and answer is the maximum among stored values. Thanks

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

how to solve div. 2 E ?

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

Please who can explain the solution to div2 B

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

    Each valid solution should contain a number that occurs in at least half of all the given pairs. There can't be more than 2 numbers with this property. Attempt to use each one and then you can check if that is possible going in any order through the array; the first time you find a mismatch with another pair, try to take one value from it.

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

    choose a[0] and check that the remaining pairs whom values aren't equal to a[0] share a commun number, if not check for b[0].

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

Why was there so many wrong submissions for d?! Is there any corner case?

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

    My solution is for every pair of leaves check if you can change question marks accordingly. But actually it's the other way around, first change ?s then every pair should satisfy the condition. I got WA and it's not a proper solution(found a testcase afterwards) Maybe also other people tried this?

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

How to solve C ??

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

There is no scoring distribution in the blog.

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

Problem E: & and &.

Maybe sunset and TLE are not familiar with well-known problems in China.

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

How to solve div 2 B?

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

    Not in Division 2, but I think this works. We do casework. Obviously, one of the two numbers in the first pair must be x or y. WLOG, let the first pair contain x, and split into two cases based on which number is x.

    For each possible x, iterate through the remaining pairs. One of the two numbers in the first pair that does not contain x must be y. Iterate through both of these possible values for y to check whether they work.

    As we have four cases and can check each case in O(N) time, this will easily work within the time limit.

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

    Check which pairs of numbers contain a[0] and then check if there is some number contained in all the other pairs (you can use map for that). Then do the same for b[0]. My solution

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

    My approach :

    • take an array temp and push 1st pair

    • push another pair which does not have any elements same as 1st pair

    • if there is no other pair then 1st pair is our answer else

    • now pair(x,y) must be one of the pairs of this 4 elements

    • take every pair and check

    • if we find at least one pair then return YES else NO

    solution : https://codeforces.com/contest/1169/submission/54683336

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

weak test case in problem B(div 2)

this is my ac code https://codeforces.com/contest/1169/submission/54686525

but for the following test case i am getting wrong answer

6 8 1 4 1 4 1 4 2 3 2 3 1 5 3 5 4 5

the answer should be "NO" but my code output is "YES"

although this is ac code

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

Hah, there are only four failed solutions in the entire Div1. A bit too strong pretests maybe?

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

Am I the only one who solved overcomplicated D1B with four bitsets?..

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

Why did my submission 54684486 fail at test 4?

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

A relatively difficult Div. 2 than usual with $$$<1800$$$ official submissions for B and $$$<600$$$ official submissions for C. But questions were interesting!

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

    It's normal because people with rating from 1900 to 2099 participated in div 1

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

Добрый вечер. Столкнулся с ситуацией что у какого- то пользователя код совпадает с моим при этом решение у него сдано позже. Kirill22/54679377, rumblefool75356/54680521 две данные посылки совпадают. Можно заметить что у данного пользователя все посылки проигнорированы, т.е. он каким либо образом узнавал чужие решения. Могу сказать что я писал в системе IDEONE и не знал , что коды там открыты для всех. Подскажите что делать в данной ситуации?

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

    Больше не писать в системе IDEONE

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

      А как оправдать то что я не давал ему намерено код?

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

        От вас ничего не требуется В этот раз для вас просто раунд будет нерейтинговым, никаких санкций в дальнейшем

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

          Можно ли избежать нерейтинговости раунда и какие меры будут приняты в сторону тех кто находят решения?

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

MikeMirzayanov, I submitted solution for Div1 B, then again after around 20 minutes I submitted solution for Div1 B with some modifications, but my earlier solution is skipped, which must be considered as per rules. What was the reason?

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

    According to the rules your last submitted solution will be considered even if your previous gave AC and the last solution gave WA.

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

    Only the last correct submission is considered for testing. The rest are skipped.

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

How Solve B.pairs problem??

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

Concise problem statement, quick systems test, quick rating update, quick editorial. Good contest!