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

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

Привет, Codeforces!

В 15.09.2019 13:35 (Московское время) состоится Codeforces Round 585 (Div. 2) для участников из второго дивизиона. Участникам раунда будет предложено 6 задач и 2 часа на их решение. Обратите внимание на необычное время начала раунда.

Раунд будет рейтинговым для участников второго дивизиона (с рейтингом менее 2100). Условия будут доступны как на русском, так и на английском языках.

Раунд начнется через 2 часа после начала квалификационного этапа и закончится с ним в одно и тоже время. Поэтому мы просим участников квалификационного этапа не распространять задачи до начала раунда. К сожалению, все задачи не поместятся в стандартный Div. 2 раунд, поэтому мы выбрали шесть из них.

Задачи вместе со мной придумывал и готовил Александр fcspartakm Фролов.

Благодарим Михаила MikeMirzayanov Мирзаянова за возможность провести зеркало квалификационного этапа и за платформы Codeforces и Polygon, Ильдара 300iq Гайнуллина за помощь в подготовке раунда и тестирование задач, а также Адилбека adedalic Далабаева и Романа Roms Глазова за прорешивание задач.

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

Удачи всем участникам!

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

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

Могу ли я участвовать в этом раунде, если я заявлен как официальный участник квалификационного этапа, но не буду участвовать в нем (согласно правилам квалификации, команда может участвовать в неполном составе)?

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

I'm newbie. i want to know how to contribute problems for contests???

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

Overlaps with atcoder bc141 D:

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

Well I did a good jod in 584

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

isn't that a clash with AtCoder Beginner Contest 141?

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

[deleted]

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

To be honest, there should be more Division 3 rounds!

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

Friendly time for Chinese users!

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

It is clashing with ABC141. Since ABC always starts at that particular time, can you please prepone this round by 35-40 mins? Many of us don't want to miss either of them.

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

Good 好好!

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

I want to take part in this contest. But whether I can take part depends on whether I can finish my homework in 4 hours and I don’t think I can. QWQ

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

Где можно смотреть монитор собственно квалификации?

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

I'm going to do screencast with commentary in English of this round first, and then jump to ABC141. YouTube

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

Friendly time for Chinese! I can participate even in my school!!!!!

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

Scoring distribution?

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

What is the hack for D?

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

Is there a simpler solution to F than 2sat with segtree?

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

    I hope 2-sat with segtree won't pass (I tried to eliminate non-linear solutions).

    The easiest linear solution is to take care of $$$f$$$ by introducing variables of the form $$$f \ge i$$$, that way every station adds only $$$2$$$ clauses (with $$$f \ge l_i$$$ and with $$$f \ge r_i + 1$$$).

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

How to solve E in this contest? Why more than 200 participants solved it?

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

Lose in the contest and Ticket Game. :(

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

Я где-то раньше видел задачу E.

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

I will become specialist,);

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

For D, can somebody mathematically prove why the average possible value of first half must be equal to average possible value of second half for Bicarp to be the winner?

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

how to do D,sos!!!

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

    I made some observations, but I may be incorrect.

    (1) If you remove a question mark from each half, the winner does not change. I could not fully prove this, but a partial proof is if Bicarp was the winner before, then adding a ? to each side means that any Monocarp's move can be countered by Bicarp by doing the exact same move on the other side. (2) So we can keep removing question marks until only one half has a question mark. Now if there are odd number then Monocarp has the last move and can always win. (3) Define difference as subtraction of question_mark half from other_half. If even then if the difference/9 = question_marks/2 then Bicarp wins, else monocarp wins (also difference%9 must be 0 and difference must be positive). This is because any move Monocarp makes, Bicarp can make a move so that the sum of their moves goes up to 9.

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

      Intuitively it hit me that it has something to do with average value of both halves. I calculated sum1= sum of first half by replacing all '?' with 0,
      sum2= sum of second half by replacing all '?' with 0,
      max1= sum of first half by replacing all '?' with 9,
      max2= sum of second half by replacing all '?' with 9, Then observed that it was Bicarp who was winning if sum1+max1= sum2+max2 and it passed. Not able to prove it mathematically as to why this is happening.

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

        Proof:

        1, as above, we can assume there are question marks only on one side 2, assume that left half has no question marks. Suppose the right string is xxxxx????. Then if Monocarp plays any value i, then Bicarp can play 9-i, and can always make the string reach the average_value as you calculated. 3, Bicarp cannot make the string reach any other value, because then Monocarp would simply deviate.

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

      After you delete same number of question marks from each side the remainder of question marks is guaranteed to be even. Let s be the remaining number of question marks and f be the difference of both halves. Now first move is made by Monocarp as there was even moves removing question marks from both sides. Now for the last part if the remaining question marks are from the bigger half, Monocarp is guaranteed to win as you can't put minus digits. Now if from the lesser half, if (s / 2)*9 == f, Bicarp wins by putting (9 — (digit monocarp put)) every turn. In other cases if (s / 2)*9 < f Monocarp just puts 0 every turn and f is unreachable. Else if (s / 2)*9 > f Monocarp just puts 9 in every turn and f is surpassed.

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

Can someone give hints for problem C?

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

How to solve B ?

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

back to green :)

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

Is there something wrong on score board?

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

Back to green :)

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

When I finished the program of problem C, the contest just had ended.I am too slow!What a pity! I need to practice more! Practice makes prefect.

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

Is there something wrong with the rating board?

I can see my E,F both accepted in status,also when i click the -1 on the rating board.

But the rating board shows that they fail in the system test(FST).

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

Is it hilarious when your code get correct on the sample testcases and times up?

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

Wow, so many WA on D...

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

Just what the heck is D test case 23, literally hacked half the solutions.

Btw, How do we solve D, and what's the intuition for it?

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

    I solved D with greedy:

    Try to maximize left half, minimize left half, maximize right half, or minimize right half for Monocarp, then if at least in one case Bicarp can't make it equal, Monocarp win, else Bicarp.

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

    Split the string into two part, calc the sum of left and right parts (denoted as s1 and s2), and how many unknown digit for each sides(denoted as c1 and c2).

    Then this problem become: there is a number s=s1-s2, you can do c1 times plus operation and c2 times subtract operation, if the result is 0, then the second guy win, else the first one.

    Now it's still difficult, so let's transform subtract operations into plus operations. Because of subtract x equal to plus y-9 while y = 9-x.So now the problem is about a number s'=s-9*c2, you can do c1 + c2 times plus operation.

    It's easy to prove only when res = s' + 9 * (c1 + c2) / 2 equal to 0, the second guy will win.If res < 0, then first guy can always plus 0 in each turn, else plus 9 in each turn.

    I don't know whether the idea is right because I haven't submited it.

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

I

hacked other's problem D successfully during the contest;

I

on problem D got a FST;

I

wrote a "if(tmp==(a-b)/9)" while it's supposed to be "if(9*tmp==(a-b))".

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

Why is the submission 60623002 still running on pretest 8

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

Its seems like Testing System is stuck in something. It says 100% for a while (longer than normal). Is there anyone know the broblem?

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

So good pretests for D

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

I got a wrong on test 9 on problem B coz i wrote (int n) instead of (long long n ) . now I feel sad , I spent time on it and didn't get it till the contest is finished .

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

Me: ratings -110 in a weekend, life sucks

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

I wrote D in a different way.

Consider their moves, at first, it must be M try to enlarge the gap between the sum, and B try to make it smaller.

So we can brute force their choices, and just consider edge cases that they need to move on the same side. It is easy to find that the maximum gap and minimum gap can M create can calculate in O(1), so the problem can be solved.

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

On problem C, why this answer: 3 {1 3} {2 6} {7 8} is not good for this test 8 babbaabb abababaa ?? It seems ok....

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

On problem C, why this answer: 3 {1 3} {2 6} {7 8} is not good for this test: 8 babbaabb abababaa It seems ok...

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

А можно уже публично обсуждать задачи квала? (те, которых не было на раунде)

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

how to solve A? I didn't get the idea

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

    My solution: (not the optimal solution)

    For the minimum: Consider C is the number of players and k is the amount of cards a player can get before being banned. Every player can receive k-1 cards and still be in the game so you can give every player k-1 cards and since every player is one card away from being banned the number of cards left is the minimum number of players. min = min_team1+min_team2; (if minimum is negative result = 0 !!)

    For the maximum: you can pick the team with the smallest k and while players > 0 and n-k >= 0 you can pick a player then n = n-k; then same for the second team. you can do this with math equations but I find Greedy easier to understand

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

    A more naive solution: Just use priority queue to simulate the process.
    My solution can be found here.

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

The 3rd Test Case in C question . I think it can be done in 2 moves rather than 3.

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

Any idea how to solve problem C, if the strings are allowed to have any characters from lowercase English alphabet?

We can reduce the strings to atmost $$$26×25$$$ length by removing matching pairs and reducing similar non matching pairs like we did with all indices where $$$s[i]=a$$$ and $$$t[i]=b$$$ in problem C. Will greedy work after that?

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

    Well, one observation is that any operation must increase the number of matching indices (s[i] == t[i]) by at least 1. So we might iterate over all pairs of indices and check whether we can make an operation such that for one of those indices, say j after the operation, s[j] == t[j]. If we find such a pair, we remove j and continue. Otherwise, we stop and if the string is non-empty, then there is no solution.

    That works in time O(alphabet_size ^ 6), which seems to be well enough.

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

The 3rd Test Case for C question . Can it be done in 2 moves rather than 3 ??

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

can someone help me the case where my solution for B fails.. My-solution

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

Editorial?

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

The editorial is out!

I am really sorry for the issue with problem E. Looks like before the contest I was too inattentive to think about solutions without subset DP and how to eliminate them. After seeing this idea in a comment, I started stressing a test against it and simultaneously trying to prove it, but by the time the countertest has been found, it was already too late (something like 2 hours after the round).

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

    How were you generating testcases?

    Spoiler

    I found this is the smallest case that should prevent people from calculating cost the wrong way and it's only 7 digits long.

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

      I tried stressing on 3 different colours and small length of the input (from 5 to 15), and only after increasing length I actually generated something useful (a testcase with $$$n = 284$$$ which breaks these solutions).

      Maybe it was bad to choose a range of possible lengths instead of some fixed length.

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

Can anyone please tell why my B passed? When I looked at it after contest and ran it through some cases, It didn't make sense. https://mirror.codeforces.com/contest/1215/submission/60621363

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

    I also didn't understand your code at first and tried to come up with countercases, but I couldn't and in the process, I came to the conclusion that the algorithm was correct.

    So here's a small proof:

    First notice that pref[i] % 2 == 0 iff the product of numbers up to i is positive.

    When calculating the number of positive subsegments, you have 3 terms:

    • The number of ways to choose two indices, i and j, such that the products of numbers up to i (inclusive) and j (inclusive) are both positive / both negative. That means that, in both cases, there is an even number of negative numbers between i + 1 and j (we use a similar property when constructing prefix sums). Thus, the subsegment (i, j] is suitable.

    • The number of indices i such that the product of numbers up to i (inclusive) is positive. This means that the subsegment [1, i] is suitable (1-based indexing).

    So we proved that all those subsegments are positive. It remains to prove that we haven't missed any other positive subsegments.

    Let's make the proof by contradiction. Assume there is a subsegment (i, j] such that the products of numbers up to i and j (both inclusive) have different signs. That means that there is an odd number of negative numbers in the interval [i, j] (again, remember prefix sums), and the subsegment is negative.

    The number of negative subsegments is simply this amount subtracted from the total number of subsegments.

    Overall, B was a bit tricky, even though it's obvious that the problem is classic. It took me the longest to solve from [A, D], and I have only a vague understanding of why my code works.

    Hope that helped!

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

А вы выложите потом этот квал целиком в виде тренировки?

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

Can someone tell what's wrong with my solution for D. I've greedily simulated the game by M increasing the difference and B reducing it. Code

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

    maybe sometimes if M reducing the difference is a better choose. like this example:

    4 ??01

    if M choose write a number>=2 on the left sum(right)-sum(lift) will be negative,and M will win. but you code will cout B.

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

This is my code for D which simulates the game optimally .My code

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

Lovely contest. Keep up the work

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

Хотелось бы поблагодарить авторов за присутствие достаточно оригинальных и нестандартных задач на полном контесте (несмотря на то, что "всего лишь" квалификация — очень качественный набор получился, идейный и с естественными формулировками). Навскидку — про шарики, игра с билетом, фонари. Наверняка что-то еще упустил.

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

Still waiting for the editorial.!

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

When will the winners be announced? :3

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

The full Qualification Stage has been added to the Codeforces Gyms.

Note that the problem "The Number of Products" is different from the one used in the round.

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

Problem difficulties have not been assigned yet.