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

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

<copy-pasted-part>

Привет! В 23.01.2019 17:35 (Московское время) начнётся Codeforces Round 535 (Div. 3) — очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 6 или 7 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Наверное, участникам из первого дивизиона они будут совсем не интересны, а для 1600-1899 покажутся простыми. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.

Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Я постарался сделать приличные тесты — так же как и вы буду расстроен, если у многих попадают решения после окончания контеста.

Вам будет предложено 6 или 7 задач и 2 часа на их решение.

Штраф за неверную попытку в этом раунде (и последующих Div. 3 раундах) будет равняться 10 минутам.

Напоминаем, что в таблицу официальных результатов попадут только достоверные участники третьего дивизиона. Как написано по ссылке — это вынужденная мера для борьбы с неспортивным поведением. Для квалификации в качестве достоверного участника третьего дивизиона надо:

  • принять участие не менее чем в двух рейтинговых раундах (и решить в каждом из них хотя бы одну задачу),
  • не иметь в рейтинге точку 1900 или выше.

Независимо от того являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.

Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацию моей работы. Спасибо моим очень хорошим друзьям Михаилу awoo Пикляеву, Максиму Neon Мещерякову и Ивану BledDest Андросову за помощь в подготовке и тестирование раунда.

Удачи!

Также хочу сказать, что участники, намеренно отправляющие неверные решения и взламывающие их после окончания соревнования (пример), не будут показаны в таблице лидеров по взломам.

</copy-pasted-part>

UPD: Я хочу поблагодарить тестеров ismagilov.code, budalnik, Arpa, filippos, eddy1021 за огромную помощь в подготовке раунда!

UDP2: Я не уверен по поводу G63-AMG, поэтому я включил в таблицу топ-6 вместо топ-5. Также я не уверен, что некоторые взломщики не читерили, поэтому простите меня, если моя информация неверна.

UPD3: Разбор опубликован!

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

Место Участник Задач решено Штраф
1 b31quocbao 7 358
2 GZY_AK_IOI 7 455
3(?) G63-AMG 6 101
4(3?) pushkar12 6 216
5(4?) _DarkDawn_ 6 226
6(5?) Amooo 6 229

Поздравляем лучших взломщиков:

Место Участник Число взломов
1 _bacali 181:-49
2 Chiakisa 55:-8
3 CNH_NHI 10:-1
4 Cylinder 9
5 CNH_NSIS 8
Было сделано 378 успешных и 348 неудачных взломов.

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Задача Участник Штраф
A spacewanker 0:01
B mpstxdy 0:03
C G63-AMG 0:06
D arpit040199 0:06
E1 G63-AMG 0:11
E2 TsingTaoDaTieWang2 0:16
F Zhao-L 0:20

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

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

I hope its not like..

DIV2<DIV3<DIV1

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

i hope it won't have any useless and pointless math involved...
also may i ask will it rate my rating?

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

    The contest will be rated for you as long as you're under 1600 (now you're 1599). If you took part in today's contest and it will raise your rating — the next Div. 3 won't be rated for you. Half of your comments are complains about maths :D I don't agree with your statement that maths has nothing to do with programming. It has a lot, especially with competitive one. All of the algorithms (e.g. graph theory) come from mathematics. Try to deal with it if you want to have fun from Codeforces.

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

Round by vovuh !! Always exciting to participate!

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

Wish a lot of AC <3

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

Div3 contest is like a gift for contestants below 1600.

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

Announcement of Codeforces Round #299 (Div. 2)?

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

Perfect announcement doesn't exi...

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

[Off Topic] I am trying to practice on my hacking skills for the next contests. Is there any good blog post about how to approach hacking effectively? Some sort of guidelines/best practices on how to hack solutions.

I searched but couldn't find any

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

Step 1 : study for exam

Step 2 : participate in Cf round

Step 3 : loose 100 rating points because your mind was tired from studying

Step 4 : fail the exam because your mind became even more tired after trying to solve problems

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

Is div3 friendly to new people?

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

    Yes, it's without a doubt the best contest new people can choose. But it doesn't mean it will be easy. If you have no or little experience in competitive programming, doing 2 or 3 problems will be a quite good result. Good luck.

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

Is vovuh nephew of Mike Mirzayanov? Why does he take every single Div3 Round?

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

Does it mean that participants with 1600 higher rating taking part in Div.3 would not be rated ?

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

Div3's are always surprising!

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

Another div 3 round, which is equal to div 2. In any case, thanks for the prepared problems. Good luck, have a fun. Take care of your feet

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

Yet again disappointed by weak pretests >:(

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

    Sorry, I tried to make strong tests in almost all problems and just forgot about you! The only tests among your solutions are in the problem B with answers 69 and 42 :(

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

      Bro just do it like a normal CF Round... please drop that 12-hour open hack feature.

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

    All of your solutions are hacked.Because "if(n==69)return 0;".

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

swap(C, D)

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

C && D giving TLE in java wow in-spite being O(N) =_=

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

    Changing the string to char array gives AC WOW! okay -

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

      String objects are immutable, which means ans+='B' requires creating a brand new String object and copy all characters, then append 'B' to it.

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

how to solve E2

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

    i think this solution is right though i couldn't find an apropriate implementation that fit in time and memory limit for it...

    first you have to prove that the answer is when you choose the segments that doesnt intersect whith the maximum element.now you can fix the element that shoud be the maximum and apply all the segments that doesn't intersect with this element and get the minimum,this can be done using segment tree

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

      I did that in E1 , assumed that each element is a maximum and chose the segments that don't affect that number

      However I don't know how to do it in E2 time limit

      how can it be done using segment tree ?

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

        you have to use minimum segment tree.

        but for the precise implementation,i couldn't get the accept for the problem,i fix the time limit problem by just a little spitting on my code,but that one agian couldn't fit in memory

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

        We do not need a segment tree here, check it out for my solution: https://codeforces.com/contest/1108/submission/48881765

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

Testcase 26 Problem F?

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

Лол, серьезно? Жадный алгоритм работает в D?

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

    А почему нет?

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

      Я, в принципе, не спорю. Просто, немного неожиданно видеть подобное решение на задачу D, пусть даже и div3.

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

Need help on C. I don't know what I did wrong.

https://codeforces.com/contest/1108/submission/48833951

BTW any recommendation for E1,E2 and F???

//swap(D,C). and maybe even swap (D,B). I lost 50 mins on C and just read D and like "Uh what???"

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

    Simply try "RGBRGB..." "RBG" "BRG" "BGR" "GRB" "GBR" and find the minimum among these choices.

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

So it's my first time to see a problem which has two types in Codeforces.

(And I haven't solved it/them.:D It should be an easy problem though..)

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

I don't know about you guys but 12-hour phase of open hacks is certanily the only thing I don't like about this Div.3 contest, why don't you leave that feature for Educational Rounds only ??? You can downvote me, I don't care about that, but I have to say it... is painful.

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

    But this is really helpful to improve your skills.

    I think that Codeforces is a site to help you improve your skills, ratings is not the only thing right?

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

      Ok, but regular CF rounds allow you to hack as well, my opinion is that it would be better to leave the 12-hour phase of open hacks for Educational Rounds only and let this div. 3 rounds more like the regular div. 2 / div. 1 rounds. Again is just my opinion. Happy codings to all :P

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

Can somebody tell me what's wrong with this code on problem E2?

My submission

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

https://codeforces.com/contest/1108/submission/48801874 i find new thing one of the guy is submitting right solution expect for case n == 69 and he is hacking with another account . please report this user and please dont allow this to happen in future the user is @problem_destroyer420

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

I did try to solve the problem E1 using DP. but I did not solve the number of segment T^T...

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

I did try to solve the problem E1 using DP. but I did not solve the number of segment T^T...

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

Am I the only one who felt today's Div3 first 3 problems are more difficult than yesterdays Div2 first 3 problems?

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

How to solve E2?

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

    For every index of the array assume that it is not affected by any of the M updates. Apply all the other updates which don't affect that index and calculate the answer i.e. max — min.

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

      how to do that in E2 time limit

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

        Apply all the queries to the given array initially. Now you can do a sweepline on the updates based on which index they appear and which index they disappear. Submission

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

        You can use sweep line technique. Iterate i from 1 to n, for each i subtract all segments [i, j], then calculate. After calculating, add all segment [j, i] so that next i won't use old segments.

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

        Check all indices in increasing order. For each index, check all the segments and find if the index is the start of the segment. If it is, then subtract 1 from all elements in the segment, and re-calculate min and max and update the answer. Check all the segments again and see if the index is the end of the segment. If it is, then add 1 to all elements in the segment.

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

          Can you explain in some detail why it works? Is it because you are trying to depress the value of the ith element as much as possible, and the highest element e such that e-a[i] gives the max answer can either be a part of that segment or not, if it is not a part you gain one, if it is you dont lose anything since both get devalued by 1? Please correct me if I am thinking of something wrong

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

            Basic principle is to make each element as small as possible. So for each element, you're going to subtract 1 from all segments including that element.

            If you check indices in increasing order, the only segments you need to check are the ones you enter or leave. This guarantees that when check an index, all segments including that element has already subtracted while others are not.

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

            Yes, exactly.

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

      Yeah, I solved E1 with that observation. But that gets TL for E2.

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

contest was so easy :D

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

Anyone tell me what happened with my solution. I just change string color = "GRB" code (WA on test 4) to color ="BGR" code and got AC?

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

    next_permutation needs your passed array to be in sorted order, RGB is not sorted, but BGR is

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

what's the dp solution for probD?

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

    State: dp(index, prev_letter)

    Transition:

    if(prev_letter != cur_letter):  
      dp(index, prev_letter) = dp(index+1, cur_letter);  
    else  
      iterate i over ['R', 'G' and 'B'] and i != prev_letter: 
         dp(index, prev_letter) = minimum_of ( 1 + dp(index+1, i) ) ;
    

    Please check my solution for more clearity.

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

can anyone tell why my code https://codeforces.com/contest/1108/submission/48851718 for problem https://codeforces.com/contest/1108/problem/E1 shows wrong answer on online ide while it give correct answer in sublime text??

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

What is the intended sol in E2? Segment tree with lazy prop didn't pass for me. (tle #15)

UPD — AC. Missed to apply sweep line on updates.

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

Someone can explain me why my position in standings changes after refreshing the page? Which of these is the official one?

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

Can anybody tell me what is wrong with my E?

I tried greedy + segtree.

Like if you want to have ai as the maximum after applying the subset of intervals applying intervals that contained ai would not help and applying intervals that do not contain ai would not damage, so I just iterated over i and do the updates :P

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

Спасибо за интересные задачи и сильные тесты

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

Can anyone explain problem F a little , I mean the sample test case 1.

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

    Initially, two kinds of MST are possible. Both uses edges (3,7), (4,8), (1,2), (1,4), (2,3), (3,5). One possible MST uses edge (1,6) while the other uses edge (3,6).

    If you increase the weight of edge (1,6), then the only MST possible now is the one that uses (3,6). Same for increasing the weight of edge (3,6) where only the MST using edge (1,6) remains.

    If you're not familiar with MST, you'd better search for it first.

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

in B, can answer to test case

4 9973 1 9973 1

be 9973 9973 ?

nowhere it is mentioned x!=y. this solution satisfies all conditions in question.

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

Thanks vovuh for this nice contest. Questions were well constructed and difficulty was also gradual :)

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

Hi guys, i work in c++ gnu g++14. I have a problem with task B. All my solutions when tested by me output correct answers but when i submit them, program always output "0 0". Any idea why is this happening ?

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

    You should only use one I/O library (C or C++) after using ios_base::sync_with_stdio(false);. i.e. using only cin or using only scanf.

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

copying alert : The submissions of the a/c LightningFrenemy213 and arpan_dg are identical.

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

How to solve E1 ?

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

    For every index in the array, apply every query that doesn't include that index, to the original array and calculate the difference (max-min).

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

      How ? Any reason for this approach

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

        What you're doing with this approach is just checking the final states of the array when that particular index is not included in any query that you've applied. There will always be a case when the difference between max — that index element and min — calculated after applying the queries, will be maximum.

        This is one approach, there might be other approaches to solving this problem.

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

Why my rating don't update?

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

O(nmlogn) algorithm of E2 48867037

I use some method to decrease the constant, and it exits when time is up.

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

I can't blieve D is much easier than C,But it's TRUTH :P

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

nice problems :D

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

Weak systests, my solutions passed

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

This round was quicker than the previous Educational round !!

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

User Iamoni coded with friends.
Problem A(48801772)
Problem C(48805698)
Problem E1(48808903)
Problem E2(48822818)
Different templates, different coding styles.

vovuh MikeMirzayanov

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

    Good catch there. Also the submission times are highly suspicious. Hopefully they will look into it.

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

can anybody help why my O(n^3) solution for B is wrong https://codeforces.com/contest/1108/submission/48890311

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

    How did you get this approach?_

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

      I tried to make all the pair of x and y from the given array and then checking for every pair whether it satisfy the given constraint for x and y , if yes then print x and y ( I still don't know what is wrong in my approach).

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

vovuh, will you publish the editorial?

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

How to solve E by segment tree? (PS: When will the Tutorial be published?

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

    A key observation is that there is always an optimal solution that selecting all segments covering a specific index (let us call it x). To look for x, we can use a sweep line to handle with the segments and use a segment tree to update the answer.

    You can see my code for more information.

    (UPD) It seems that someone has answered the same approach before :(

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

Недостаточно прав для просмотра разбора(

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

Editorial Page is not working for me! does someone else has this issue too?

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

48837239 — what is the issue with this?

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

Why are you not sure about Lamoni?