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

Автор AGrigorii, 8 лет назад, По-русски

Привет, Codeforces!

В 17.05.2018 19:35 (Московское время) состоится очередной раунд Codeforces #484 для участников из второго дивизиона. Традиционно, участники из первого дивизиона приглашаются поучаствовать в соревновании вне конкурса. Как обычно, обратите внимание на необычное время начала раунда.

В этот раз задачи для вас готовили я и Андрей API Пикас.

Хотелось бы поблагодарить Николая KAN Калинина за помощь в подготовке задач и координацию раунда, Михаила MikeMirzayanov Мирзаянова за замечательные системы Codeforces и Polygon, а также Кирилла kittylover Самелюка, Николая Apollon76 Пермякова, Дмитрия Krainov_Dmitry Крайнова, Андрея GreenGrape Райского и Алексея Um_nik Данилюка за прорешивание задач и ценные советы.

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

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

До встречи!

UPD Разбалловка 500-1000-1500-2000-2500-3000

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

  1. Kotori_Is_My_Wife

  2. vosptu

  3. ez_zkj

  4. relativity

  5. iordache.bogdan

А также победителей двух дивизионов:

  1. Claris

  2. Benq

  3. Kotori_Is_My_Wife

  4. kmjp

  5. vosptu

UPD3 Разбор будет опубликован завтра.

UPD4 Разбор

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

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

Six task in two hours. I think enjoy it all.

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

Твой прошлый рануд был интересный, верю, что и сейчас что-нибудь прикольное будет)

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

Is there div 3 and is div 3 rated?

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

Great :). You could fix timeanddate.com link to make it display time in user's timezone. Take a look on Mike's comment: http://codeforces.me/blog/entry/59322?#comment-429178

Displayed time screenshots of #483 and #484:

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

Yeaaa! Round by my favourite problemsetter! I waited it so long. <3 <3 <3

I think, I can become Candidate Master tomorrow.

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

Thanks to all, who have create this contest !!! for giving us opportunity to test our skill . such a big platform

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

Third palindrome round in 2018 !!

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

...

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

I smell a lot of hacks

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

Q. Why do you start blushing when a new Codeforces round is announced?

A. It turns me Red. ^_^

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


Reading comments be like...

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

is it rated for purples ?

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

Should have a contest on yesterday. 13,14,15,17....why missed 16??

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

123

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

What about for Div 3 members?

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

А может всё-таки запотеем на претесты и без взломов?

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

    Когда-нибудь люди поймут, что поймать в семи-восьми претестах все ошибки, которые способны допустить шесть тысяч человек, решительно невозможно :)

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

      Нет взломов не от слова совсем. Нет взломов, значит в топ не попадают парни с +30)

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

      А мне кажется, что возможно! Можно же не обязательно брать фиолетовых+ чуваков тестировать раунд) Берите зелёных, бирюзовых, синих. Чем меньше опыта, тем больше ошибок) Так почти все случаи и найдутся

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

Как обычно, обратите внимание на необычное время начала раунда.

Как же я обожаю эту фразу.

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

Wish high ratings to all.

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

I hope this round won't be like that 1vldm8

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

better starting time for Bangladeshi contestant....

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

Can't open problem C and D. Showing Error !!

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -12 Проголосовать: не нравится
Комментарий удален по причине нарушения правил Codeforces
»
8 лет назад, скрыть # |
 
Проголосовать: нравится +66 Проголосовать: не нравится

How to solve F?

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

    If we look at the dfs tree of the graph:

    • If we got any backward edge (an edge connecting a node to one of its ancestors) then the answer must be one of the nodes between the two endpoints. If there is not such edge then answer is -1.
    • If we got another backward edge then we need to find the intersection (or remove nodes from solution which are ancestor of the other node or are not ancestor of the current node). For example, 1 -> 2 -> 3 -> 4 is a cycle, and 2 -> 3 -> 5 is another cycle. Both 4 -> 1 and 5 -> 2 are backward edges.

    • If we got a cross edge (edge connecting a node to another that is neither its ancestor or descendant) then if the other node is in cycle and topmost node of the cycle is a parent of the current node, we need to erase the nodes that are neither parent to the current node nor descendant of the other node. For example, 7->4 is a cross edge.

    Submission as a reference: 38382900

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

      Hi there, I am struggling hard with this problem. So I studied your code quite a bit, and found a mistake in it. Try the following test case:

      6 9
      1 2
      2 3
      3 4
      4 1
      4 2
      3 5
      5 6
      6 4
      1 6
      

      Solution should be 4, but your program answers -1.

      The last edge 1->6 in this test case is a cross edge. So you have to delete all vertices on the cycle 1->2->3->4->1 that are anchestors of 6, but not of 1. Finding the lowest anchestor of 1 on the cycle works (it is 1 itself). But finding the lowest anchestor of 6 doesn't work, since you argument with the height h of 6, which has nothing to do with the ancestors.

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

How to solve problem D?

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

Problem E can be solved by the fact that this rectangle can be mirrored adjacently on the coordinate plane.

No, I didn't solve it.

I've done a similar problem in Google Foobar. If I had been given 40 mins I could've solved it. :(

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

What is the 6th pretest in C?

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

Problem C is available at Hacker Rank: Your text to link here... . Check this out..

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

I read "connected components with equal size" instead of "even size" in C. Yikes

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

Feedback:

C: nice

D: A bit ambiguous, I needed two clarifications to understand it.

E: The mirroring trick is very standard. I think I've seen a very similar (maybe the same) problem in uva.

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

I used tree dp to solve C but now i find out that there's some simple solution -_-

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

Очень расстроила задача F. В ней всего в одном месте неявно указано, что граф ориентированный («дороги односторонние»), после чего никаких упоминаний или рисунков со стрелочками или любых других намеков на ориентированность нет. И тесты из условия тоже очень легко воспринять за неориентированные, причем код для неориентированного случая их проходит. :(

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

    Дороги в Брагинске односторонние

    будут продолжать ездить по односторонним дорогам

    количество перекрестков и односторонних дорог

    начало и конец i-той односторонней дороги

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

      Перечитал. Действительно, все так, не знаю, как я все это просмотрел. Приношу искренние извинения составителям.

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

So are you sure what you want us to find in D is what D's statement says?

Thus, in the sequence of n days we can find consecutive nonempty segments when the shark traveled the distance less than k in each of the days: each such segment corresponds to one location.

Shit in bold's true but it it's not true that each location has a corresponding nonempty set.

Now getting back to what the problem asks for:

Find such integer k , that the number of locations is as large as possible.

And at the same time, what you want us to do is find the k which maximizes the number of nonempty sets, not the number of locations.

Even after the announcement, which was too late anyway, nobody bothered to actually update the statement.

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

    This is because if a shark travels 2 days in a row, he will still be at a new location on the day in between, correct?

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

    After reading the problem statement I thought the answer to this test case 8 1 2 7 3 4 8 5 6 should be 0 as it satisfies all the conditions asked i.e 1) the shark was in each location the same number of days, 2) the number of locations is maximum possible satisfying the first condition, 3) k is smallest possible satisfying the first and second conditions

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

      I have the same confusion regarding this problem (but not anymore). Let me help clarify this. Assume the answer is k, one location is counted as non-empty consecutive segment which every number in it is strictly lower than k.

      For first sample case, if the answer is 7, the number of location is 3, that is {1,2}, {3,4}, {5, 6} and valid because each segment size is two. If you choose 0 as the answer, the number of location is zero. So there's a better answer than 0.

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

Happy Ramadan holiday to all. I wish happiness and health to everyone.

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

Было бы здорово, если б люди, знающие задачи, не сабмитили код во время раунда. А то всякие с 300icq интеллекта засылают верное по F на 4ой минуте, после чего создается стойкое ощущение, что можно пихнуть хрень и кода должно быть мало.

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

    Задачи раунда я до начала не знал, если ты об этом

    Ну и я хотел написать раунд полностью (а зарядка ноута, как оказалось, не хотела), и не видел смысла писать решение и так известной мне задачи

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

This statement didn't exist at the beginning of the contest. My solution was hacked because of it. and there was no clarification about it!!!!!!! AGrigorii [ ](Ca)

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

A question copied directly from geeksforgeeks, wtf ???? Contest should be unrated.Its a big disgrace.

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

Was not able to open all problem statements in one window :( Bug

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

How to solve C?

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

o.O

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

What topic should i learn to solve C div2?

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

Almost same as today's Problem C Is there any difference conceptually ???? May be it is not what the contestant expect from the problem setter..

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

Капец в А там же написано было, что не может 1 и последнее место быть соседним, а потом только же добавилась приписка, что n != 2?? Так же не честно... Если я не прав, напишите.. странно.. разве я мог не увидеть..

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

    n = 3, 101, вот тут 2 единицы соседними не являются

    n = 2, 11 а вот тут являются потому что n = 2(ваш КЭП)

    Т.е условие говорит что первое и последнее место являются соседними только в одном случае — когда n равно 2.

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

      Изначально, насколько я помню условия что первый элемент и последний не соседи было написано так, а потом добавили что это не так при n == 2

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

      Не знаю, зачем ты это объяснил, это очевидно. Проблема в том, что пояснения про случай n = 2 не было в начальном условии, а когда оно добавилось, не было кляра. Конечно, глупая описка, но кого-то могло ввести в ступор.

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

чё-то изи

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

How to solve C if it would have been a graph with cycles ?

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

About the choice of wording in condition 1 of A

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

In Question B why doesn't 3*nlogn pass the test cases. I tried using maps in c++ but it is showing time limit exceeded in test 45 . Can someone point out mistake in my code : Link

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

Yay, I became master, but sadly only because of div2 rounds.

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

    What is the difference? Master is master. If you don't want to participate in div 2, then wait for div1...

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

    I don't understand why everybody is complaining and thinks that it would be easier to get to 2100. The only true thing is that there will be more opportunities to get there. It doesn't mean it would be easier. If you don't deserve 2100 you won't get it, one way or another.

    For example I already managed to lose a lot of points in div 2 contest on Monday. And today I was 122. If there were no violet coders, I would have been 25'th which would have given me much more rating.

    • »
      »
      »
      8 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится -31 Проголосовать: не нравится

      Lol You don't understand? Before this shit revolution, to get Master(old) you need to most likely solve 3 probs in Div 1 which is equivalent to all div 2 problems. Now get just good ranks which in most case is possible with just 4 div 2 problems. As you can see in this round, 370 officially solved 4th hardest, you think thats good enough for someone Master?

      "I don't understand why everybody is complaining and thinks that it would be easier to get to 2100" Because it actually is faggot. If you don't understand, then compare how many users have got there maximum rating in past div 2 only rounds.

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

    You've became at least, not like me :D (9 points)

    Congradulations!

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

It looks very strange that O(nlogn) solution for D works without any used memory: 38374872.

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

speed of light coder !! ****

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

I think systests on D are very weak. I found a big mistake in my code after submit but surprisingly gave me an AC. My AC code: http://codeforces.me/contest/982/submission/38384511 A simple test case when my output differs from another AC submissions: 11 7 9 8 100 1 2 3 200 4 5 6 There something invalid in this input?

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

In Problem B What if the number of extroverts(1) at any point becomes greater than number of introverts(0)? Many solutions will fail then ![problem:982B]

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

Can someone help me in understanding D ...??

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

    For each different k[i] = a[i]+1, you check the size of all the contiguous days with a distance covered strictly less than k[i].

    You go through all the a[i] in ascending order.

    if a[i] does not have a neighbour lower than him, it creates a new contiguous day sequence of length 1. Then, you merge it with his neighbour(s) (if they are lower than a[i]), which destroys their sequence and creates a new sequence of length 1 + total length of the sequences of the neighbours. It's important because you need to keep track of how many different lengths of sequences you have at all time, cause you will need it at each step.

    To keep track of how many different lengths of sequences you have after each a[i], you can create a table that tracks how many sequences each length has, and a variable that tracks how many lengths you have (that you increase by one each time you insert a sequence whose length is not represented yet, and decrease whenever you remove the last sequence of a given size). If there is only one length in the table, then you know that the number of sequences for k[i] is (number of distances <=a[i]) /(only length of sequence represented).

    The answer is the minimum k[i] that leads to the maximum value of this ratio. You can do the merge with an union/find, making the merging a O(n*log(n)), and computing the ratio each time can be done in constant time, leading to (I think) a solution in O(n*log(n)).

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

AGrigorii When is the editorial gonna be published? If it's already published in Russian, please do provide the link. Thanks

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

I found a surprisingly simple solution for F. The key observation is that if you have a node with an outdegree of 1, you can delete that node and push all incoming nodes to the successor (with a special case for self-loops). This process can reduce the number of edges if an incoming node was already pointing to the successor node.

As an example, node 3 in the image below can be deleted since it has only one outgoing edge:

Which results in:

Note that this reduced the outdegree of node 1, making it now eligible for deletion.

If you have more than one node remaining after this reduction, then the answer is impossible. I haven't tried to prove this, but it resulted in an AC submission. :)

For each node, it is essential to maintain an unordered_set for incoming and outgoing nodes to detect duplicate edges. This makes it slightly slower (due to the set operations), but it's fast enough to pass in C++ (albeit not in Java, from my experience). My accepted submission: 38409568.

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

    I thought about a proof of your solution, and I think it is correct. If anyone find any wrong with it, just point out the wrong point.

    The first part is about the validity of deleting the point with one out-degree. We can think about a point u that satisfies the requirement and we call v is a point that have a direct edge to u. We can easily find that every circle that pass the edge u-v must pass the point that u can only arrive at. So we can think u is useless and delete it from the graph (of course it contains the process of changing some edges).

    The second part is about why the answer is impossible when there are more than one point remained. Now, the graph satisfies every point has at least two out-edge, of course we can remove arbitrary out-edge to make every point's out-edge is two. Then we build the dfs tree of the graph, and it is a binary tree. We only need to discuss about the out-edge of the leaves. We assume that this graph is valid for answer. Then we need to construct the out-edge of the leaves by a optimal way to make the graph is valid. So we can first make every leaf link to the root, and the other out-edge link to the next leaf in a way you like. But we will find that one leaf can't make another link because it wouldn't be valid no matter where it connect to. So we can prove this part.

    This solution has a drawback is that it can't output all the points that satisfy the problem. But it realy easy to type.

    (If there are many grammar errors, please don't blame me. Because my English is realy not good.)

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

I did not manage to solve div2-C using Python 2. My submission 38369140 got runtime error. I think the issue is recursive calls. Is there a trick in Python to get this code AC?

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

Who can tell me what's the meaning of 'even size' in Problem C. The 'even' means equal? or %2==0??

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

Request: Please post the editorial link with problems for this contest. Had a hard time to find this post to find editorials.