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

Привет, Codeforces!

В 27.12.2019 17:40 (Московское время) состоится Educational Codeforces Round 79 (рейтинговый для Див. 2).

Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Удачи в раунде! Успешных решений!

Так же от наших друзей и партнёров из Harbour.Space есть сообщение для вас:

Привет Codeforces!

Еще доступны последние места на курс Михаила MikeMirzayanov Мирзаянова "Advanced Algorithms and Data Structures", который пройдет в Барселоне с 6го по 24е января, 2020.

Курс состоит из трех недель обучения, 5 дней в неделю. Программа включает в себя ежедневные лекции и практические занятия. Это будет интересно!

Помните, что существует специальная цена 1,000 евро* для всех пользователей Codeforces.

* Цена не включает в себя расходы на проезд или проживание.

Если Вас это заинтересовало, отправьте нам сообщение на hello@harbour.space и мы расскажем что делать дальше.

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

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

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

Hope to become specialist in this round

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

Wow, that's amazing!

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

Just Misusing Santa's Gift

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

Div3 registration has started, we could see some blue, or even purple participating officially and rated in div3 contest! UPD:Probably grandmasters in div3 now! Santa is real!

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

Надеюсь стать мемом в этом раунде

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

.

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

.

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

CODEFORCES SANTA BRINGING GIFTS IN THE END OF YEAR.

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

Is the weird color thing going on the Christmas gift from CF? Yup

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

Anyone else experiencing the slowness of the website at the moment? Its just taking longer than usual

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

5 minutes delayed :(

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

Delayed

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

delayed :/

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

why there is no sample test case explanation in c problem

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

When Speedforces meets slow website ...

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

Thanks to the authors for educational, I will be glad if all my decisions fall P.S. you can have as many tasks with t requests as possible, I love them so much

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

Participants.

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

по-моему это как-то связано с задачей F

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

How to solve F?

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

how can God_particle be a legendary grandmaster? he has a highest rating of 1404

In this contest i got confused by a legendary gm just after my ranking and thus found this user

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

PROBLEM D: How is the answer of first test case 7/8? (without modulo) As per me — TOTAL POSSIBLE ARRANGEMENTS OF DECISION ARE: (2 1 1) (2 1 2) (1 1 1) (1 1 2) (1 2 1) (1 2 2) ie: 6 total possibilites, out of which 5 are valid, so the answer should be 5/6

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

    i had the same doubt

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

    Due to the process with which the decision is made, not all of those are equally likely. The first two happen with probability $$$\frac{1}{4}$$$, the last four with probability $$$\frac{1}{8}$$$ each.

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

    1 1 1 and 1 1 2 and 1 2 1 and 1 2 2 have all 1/8 chance

    2 1 1 and 2 1 2 have all 1/4 chance

    X, Z all chosen independently but Y is not (depends on X)

    P(X = 1) = P(X = 2) = 1 / 2

    So P(X = 1 and Y = 1) = 1 / 2, P(X = 2 and Y = 1) = 1 / 2

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

    Same doubt. Anyone can explain why 7/8?

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

    Either you pick item 1 or item 2. Probability of picking item 1 is 1/2*1 (you pick student 2 ) + 1/2*1/2 (or you pick student one in the first step). Therefore probability of picking item 1 is 3/4. Probability of picking item 2 is therefore 1/4 (sigma has to be 1). Now if you pick item 1, probability of making a valid decision is 1, but if you pick item 2, probability of making valid decision is 1/2. Therefore P(pick item 1)*P(valid | item 1) + P(pick item 2)*P(valid | item 2) = 3/4 + 1/8 = 7/8

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

    Because not all of them are equally probable. (1 1 1) has 1/2*1*1/2 chance of being chosen while (2 2 2) has 1/2*1/2*1/2.

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

    That's not true Answer is 7/8

    Model of calculations:

    1) possibility to choose a person = 1 / n 2) possibility to choose a gift from a list = 1 / size_of_list; 3) possibility to choose a person who would like this gift = number of good kids / n; Lets sum everything i = 1, j = 1, 1/2 * 1/2 * 1/2 = 1/8 i = 1, j = 2, 1/2 * 1/2 * 1 = 1/4 i = 2, j = 1, 1/2 * 1 * 1 = 1/2 ans = 1/2 + 1/4 + 1/8 = 7/8

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

    This is because all tuples are not equiprobable. Let you have 10 balls then probability of selecting each ball is 1/10. Now divide the ball into two groups of 8 and 2. Now first select a group then select a ball. Then half of the probability will be distributed among 1st group and half will be distributed among second group. If a ball is in group containing 8 then probability of selection 1/16 and for other group it's 1/4. This is how 5/6 become 7/8 here.

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

Well-balanced round lol

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

The gap between D and E is SOOOOOOO HUGE (to me)

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

How to solve E?

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

    I think it can be solved using the observation that any good permutation is a one where $$$p_1=i$$$, and values of $$$p_j$$$ ($$$1\leq j\leq i$$$) are $$$\leq i$$$, $$$p_{i+1}=k$$$, and values of $$$p_m$$$ ($$$i+1\leq m\leq k$$$) are $$$\leq k$$$, and so on. Then we can use some greedy and dp to find the required permutation.

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

    I finish impl just now.. find kth-lexi painful..

    note good form is |i... | j...| k...|..., each region is cycle. with max be first.

    first define f[n], total-derangement, i.e. p[i]!=i, but they're exactly one cycle.

    r.relation $$$f[n] = (n-1)f[n-1] = (n-1)!$$$. which is circle-perm.

    define dp[n][j], ways of good-perm. s.t. first j elements in a cycle with j is first. i.e. j,..., where ... part is f[j-1].

    define g[n]: ways of good-perm of [n], i.e. $$$g[n]=\sum_{j=1}^n dp[n][j]$$$.

    r.relation $$$dp[n][j] = f[j-1] * g[n-j]$$$.

    for kth-lexi. first iter j, find satisfied dp[n][j]. then problem separate to j part, n-j part. where n-j part is original problem.

    for j part, first of all, let $$$p[1]=j$$$, then for remain position, pick smallest x, don't violate total-derangement, and just satisfied lexi.

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

Since no one is asking, how to solve E and F?

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

I have a small doubt. Will be very happy if someone can answer this. Is the cf rating predictor working fine or is there a possiblity of some discrepancy in it because of cf magic?

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

What was the test case 5 for problem D What could be done to prevent long value overflow in problem D

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

    You are trying to maintain the probability value of each event as fraction. Then you are adding all those values to compute final answer, overflowing can easily happen when you multiply numerators of fractions to bring them in common denominator form. (While adding fractions)

    Instead of doing so, immediately convert the fraction into "numerator.(denominator)^-1" (inverse modulo of denominator) form.

    and now the add the fractions in their "converted form", using appropriate modular arithmetic.

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

The gap between D and E is SOOOOOOOOOOOO HUGE

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

Can someone help me understand why the answer to the first test case in Problem $$$D$$$ is $$$7/8$$$ ?

According to me, there are $$$6$$$ possibilities totally.

  • We choose $$$x = 1$$$, Now, we have $$$2$$$ options for $$$y$$$ and $$$2$$$ options for $$$z$$$. This is $$$2 \times 2 = 4$$$ different choices
  • We choose $$$x = 2$$$. Now, we have $$$1$$$ option for $$$y$$$ and $$$2$$$ options for $$$z$$$. This is $$$1 \times 2 = 2$$$

Totally, there are $$$4 + 2 = 6$$$ choices, out of which only $$$(1, 2, 2)$$$ is invalid.

Please help me.

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

    1 1 1 and 1 1 2 and 1 2 1 and 1 2 2 have all 1/8 chance

    2 1 1 and 2 1 2 have all 1/4 chance

    X, Z all chosen independently but Y is not (depends on X)

    P(X = 1) = P(X = 2) = 1 / 2

    So P(X = 1 and Y = 1) = 1 / 2, P(X = 2 and Y = 1) = 1 / 2

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

    Look, the probability that we choose the three $$$(2, 1, 2)$$$ is not equal to the probability that we choose the three $$$(1, 1, 2)$$$.

    How the answer is counted:

    • the probability that we choose $$$(1, 1, 1)$$$ is $$$\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{8}$$$ , and this is correct;
    • the probability that we choose $$$(1, 1, 2)$$$ is $$$\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{8}$$$ , and this is correct;
    • the probability that we choose $$$(1, 2, 1)$$$ is $$$\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{8}$$$ , and this is correct;
    • the probability that we choose $$$(1, 2, 2)$$$ is $$$\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{8}$$$ , and this is not correct;
    • the probability that we choose $$$(2, 1, 1)$$$ is $$$\frac{1}{2} \cdot \frac{1}{1} \cdot \frac{1}{2} = \frac{1}{4}$$$ , and this is correct;
    • the probability that we choose $$$(2, 1, 2)$$$ is $$$\frac{1}{2} \cdot \frac{1}{1} \cdot \frac{1}{2} = \frac{1}{4}$$$ , and this is correct;

    We just summarize all the correct options and get the answer. It is equal to $$$\frac{7}{8}$$$.

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

Why was the round sooooooooo unbalanced? Like if you solved tasks A-D, the contest is ended for you. And if you solved tasks A-D not so effectively, then you definitely lose your rating. Hope to see more balanced contests on Educational Codeforces Rounds. :)

Happy New Year and Merry Christmas, by the way!

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

How to solve F?

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

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

    As others have mentioned, the solution relies on a technique known as Aliens' Trick. This is essentially a DP optimization for problems where we want to perform $$$K$$$ operations, each with some "value" (in this case, the value of an operation would be the number of characters we convert from lowercase to uppercase, assuming we're trying to minimize the number of lowercase letters, or the other way around). There's a natural $$$O(NK)$$$ solution, of course, but Aliens' Trick allows us to optimize this to $$$O(N \log X)$$$, where $$$X$$$ is a value related to the precision of the solution.

    The trick is fairly simple: essentially, rather than trying to compute the best we can do with $$$K$$$ operations, we assign some "cost" to each operation and attempt to maximize the number of uppercase letters in the final string minus the cost times the number of operations, while allowing ourselves to use any number of operations. In other words, each operation decreases our score by a certain cost. In this problem, we can easily determine the best solution given a fixed cost in $$$O(N)$$$ using some fairly simple DP. The trick, then, is that we can binary search for the greatest possible cost that will make us use at most $$$K$$$ operations. Then, we can reconstruct the answer using that cost, solving the problem.

    Thus, for this problem, we split into two cases--in the first case, we try to convert as many letters as possible to uppercase, and in the second, we try to convert the letters to lowercase. The two cases can be handled identically. Within each case, we binary search for the cost of setting a substring of length $$$L$$$ to uppercase/lowercase, keeping track of how many operations we use for each cost (using the aforementioned $$$O(N)$$$ DP). Then, we can find the cost that ensures that we use $$$K$$$ operations: if a certain cost encourages us to use too many operations, we should try a higher cost, and vise versa. This lets us reconstruct the answer in either case, and we can simply print the better of the two results.

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

For me, 'F' reduce to this problem
"Given n segments, select k from them such that they cover maximum points"
Is this some classical problem?
May be i am in completely wrong direction.

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

    This reduction has removed some (potentially useful) restrictions on the input. Notice that all n of the segments have the same length, so the value of two adjacent segments differs by 0, 1, or -1 only. I don't know that you have to abuse this restriction to solve the problem, but it exists and isn't in your simplification.

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

It's high time we explained why the answer for test 1 in D is $$$\frac{7}{8}$$$.

It seems that possible decisions are $$$(1, 1, 1)$$$, $$$(1, 1, 2)$$$, $$$(1, 2, 1)$$$, $$$(1, 2, 2)$$$, $$$(2, 1, 1)$$$ and $$$(2, 1, 2)$$$. Among them only $$$(1, 2, 2)$$$ is invalid. So the answer should be $$$\frac{5}{6}$$$, right?

Nope. These decisions are not equiprobable. The probabilities of choosing $$$x = 1$$$ and $$$x = 2$$$ are both $$$\frac{1}{2}$$$. But if we choose $$$x = 1$$$, there are two options for $$$y$$$: $$$y = 1$$$ and $$$y = 2$$$; and if we choose $$$x = 2$$$, there is only one option for $$$y$$$: $$$y = 1$$$.

So, the outcomes $$$(2, 1, 1)$$$ and $$$(2, 1, 2)$$$ are twice more probable than all of the other outcomes. That's why the probability of $$$(1, 2, 2)$$$ is just $$$\frac{1}{8}$$$.

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

**Happy new year for all !!! & I'm very happy for this round !!! **

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

How to solve A and C? :'(

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

How to solve F?

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

problem B confused me a Lot solved it in 22 attempt!

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

Test case 3 of C?

I did with maintaining a visited array concept. You can check my submission. My code — https://mirror.codeforces.com/contest/1279/submission/67746000

I tried my code on various cases but it failed. Any help?

Thank you :)

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

Hello, dear awoo, it seems to me that you would be good at doing olympiads for mathematicians!

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

Dont understand why my C is wrong? Seems such an easy problem -> https://mirror.codeforces.com/contest/1279/submission/67724577

Probably I am not understanding the problem correctly, can anyone take a look as the wait is going to be too long!!

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

    Okay, I figured out that this is because of a peculiar reason in Java that I encountered first time, and maybe will helpful to others, so putting it here. I had Integer (not ints) values in the array, and I was using the comparison !=. This works fine for numbers in the range between -128 to 127 because Java is handling it separately (see this). However for numbers outside of that range, it treats it differently. When I used the equals method instead, the same code passed.

    Kind of annoying, for 1.5 hours, I was trying to see what is wrong in my approach, including things like misinterpreting the problem etc. For example, I had implemented another approach which was giving even lesser results and so on..

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

Proof for A?

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

    If a > b + c + 1 or b > a + c + 1 or c > a + b + 1 then its impossible. In the other case, it's always possible to construct it like 1 2 3 1 2 3 .. 1 2 3 2 3 2 3 2 3 ( 1 is the biggest 2 is the second and 3 is min) and if there is 1 left we can place it between 2 and 3 in the triples.

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

    If the max count among the counts of b, r, and g is $$$mx$$$, the 2 minimums are $$$mn_1$$$ and $$$mn_2$$$, then we obviously can't make a valid configuration if $$$mn_1+mn_2 \lt mx-1$$$ (we will definitely have 2 of the max color adjacent to each other). But what is the proof that we can always find a valid configuration if $$$mn_1+mn_2 \gt mx-1$$$? Consider the case when $$$mn_1=mn_2=mx$$$, assuming without loss of generality that the max color is r, you can obtain a valid configuration of the form rgbrgb...rgb, and for every $$$mn_1$$$ and $$$mn_2$$$ values where $$$mx-1 \lt mn_1+mn_2 \lt 2*mx$$$ you can always remove an instance of b or g without making two r's be adjacent to each other.

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

query contest

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

Can someone help me figure out why am I getting Runtime Error in Problem D Test case 3. Here is my submission 67746943

UPD: I am not able to understand what the diagnostics are saying.

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

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

I know D was simple for many including myself, but while solving it, did anyone have analogies with neural networks like me ?

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

Did someone fail in D at test case 37?

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

Why doing long long int got accepted (https://mirror.codeforces.com/contest/1279/submission/67744302) in problem C whereas int was failing (https://mirror.codeforces.com/contest/1279/submission/67739629) on test case 3 ?

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

Legendary steeped CF =)) everywhere. I wish try once :>

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

I thought the items in problem D are numbered from 1 to n after reading the sample data, and this cost me 1h30m to debug my code... Now I know those are not numbers but items' names. I think I may not be the only one who made this kind of mistake.

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

I hate problems like D _ I now the solution,but can't implement it,because there is MOD,can anyone help me to learn how to do problems with MOD? I am having issues with it so long...

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

so huge difficulty gap between D and E

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

I can't solve problem D because of not attending Math class at University. :((

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

What's the hack test for B?

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

can anyone tell why this case is showing 6 on this test case on an accepted solution. Problem B:-

6 26

1 1 1 23 109 110

value of s is 26 so according to me it's not possible to reach till 6 so how it can skip 6th part.According to me answer should be 0. Did I understand the problem wrong? Please tell someone.Thanks.

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

Surprised that so less people used binary search in B.

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

What are the hacking test cases for 1279F - New Year and Handle Change ?

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

Can anyone tell the value p/q of second test case in D?

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

how to solve B?

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

Can someone please help me debug my Problem D solution? Thanks in advance. https://mirror.codeforces.com/contest/1279/submission/67745426

The problem I face is in test case 37 where this code is outputting a negative number.

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

Hack for B ?

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

Is there any point in reporting people (if I happen to notice them) intentionally creating solutions from secondary accounts and hacking them?

For example, 67741362.

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

Can someone please explain solution for Problem D ?

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

    For each gift, store the count of kids wanting it (cnt[ki]). The probability of selecting a kid is 1/n and the probability of selecting a particular gift for a kid is 1/size(ki), and probability of selecting a kid with having same gift is cnt[ki]/n.

    Total prob for particular gift being valid decision = (1/n)*(1/size(ki))*(cnt[ki]/n)

    Answer will be summation of all such prob.

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

can someone explain the idea for solving B problem please?,i didnt get idea

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

When will ratings get updated?

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

How come div 1 people are there in final standings was this round unrated??

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

In problem B, what will be the output for the test case: 1 3 11 2 9 1 I think it should be 1. But when I checked the code of various others, their output varies between 0, 1, 2.

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

    You have to maximize the no. of songs you can take. In this, there's no way of taking all 3 songs, so you can take atmost 2 songs. But, for that, you may exclude any song or not exclude any song at all, you may still be able to take only 2 songs. So, the possible answers are 0, 1, 2, 3.

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

how to slove C? I can only think of a O(n^2) approach.

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

    The optimal strategy is: each time you take a present, sort all presents above it in the order in which you will take them. So, when you take a present, if you already took some present that was under it, it will take 1 second to take it and otherwise it will take 2k+1 seconds (k is the number of presents above it).

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

Was this round Unrated??

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

Was this round Unrated?

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

Were there only 6 tests in problem B during the contest? And none with overflowing int.. hmm why!

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

Waiting for editorial.

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

Upload the editorials now? I can't wait to learn how to solve D

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

PROBLEM (A)

what about this line????????

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Note that it's ok to have lamps of the same color on the ends of the garland.

if i put 6 3 1 will it be okay?

because there 2 lamps will be the same color!! right or wrong?

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

    Garland actually is a closed loop. If you had 5 red, 3 green, 1 blue, then a possible garland would have been $$$X-\color{red}{R}-\color{green}{G}-\color{red}{R}-\color{green}{G}-\color{red}{R}-\color{green}{G}-\color{red}{R}-\color{blue}{B}-\color{red}{R}-X$$$

    Note that the two $$$X$$$ characters will be joined together when the garland will be worn, and then essentially two Red will come together.

    But the question says that don't worry about satisfying the different coloured neighbours condition on closed loop, only worry about opened garland.

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

In Problem E: I cannot understand how for input: 5 15 (In the given test case) ans= 3 1 2 5 4 Because all the possible permutations using 5 digits in lexicographical order are:

  • 1 2 3 4 5
  • 1 2 3 5 4
  • 1 2 4 3 5
  • 1 2 5 3 4
  • 1 3 2 4 5
  • 1 3 2 5 4
  • 1 4 2 3 5
  • 1 5 2 3 4
  • 2 1 3 4 5
  • 2 1 3 5 4
  • 2 1 4 3 5
  • 2 1 5 3 4
  • 3 1 2 4 5
  • 3 1 2 5 4
  • 4 1 2 3 5
  • 5 1 2 3 4

Can someone please explain me?

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

how to solve D? I feel it complex to get the probability when there's a lot of data. I can get 7/8 in example 1. I want to know how to get it in a easy way.

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

    Since the values of present for each kid are distinct. Let the number of presents each of the n kids want be k1,k2.....kn respectively. Now Let us denote the values of presents that the first kid wants to be b1(1), b1(2), b1(3), ............., b1(k1) Similarly for the second kid b2(1), b2(2), b2(3), ............., b2(k1)....and so on for other kids.

    Since the presents are distinct each available present can int the list of say d number of kids where d may vary from 1 to n. We can create a map to store the number of kids that want present i at index i of the map.

    Now the choose in the way it is given in the question i.e. using all the three steps but consider only the valid ones.

    So, probability to choose any child =(1/n) say the chosen kid is 3rd one .

    Probability to choose any one of his present=(1/k3).

    Say now the present chosen is denoted by b3(p).

    Now the third step assigning is present it to any of the n kids. But we want it to be assigned to a kid who actually wants it. Then only that will be valid.

    The number of kid that actually wants it we can get it from map, by mp[b3(p)].

    So, now the probability that the present is correctly assigned =(mp[b3(p)])/n, where n is total number of kids.

    So as a whole for that particular b3(p) present selected we have probability of (1/n)*(1/k3)*(mp[b3(p)])/n).

    Do this for all the presents for every kid.

    i.e.

    1/(n*n) *[ 1/k1 *{ mp[b1(1)]+ mp[b1(1)]+ mp[b1(1)]...+mp[b1(k1)]} +1/k2 *{ mp[b2(1)]+ mp[b2(1)]+ mp[b2(1)]...+mp[b2(k2)]} + 1/k3 *{ mp[b3(1)]+ mp[b3(1)]+ mp[b3(1)]...+mp[b3(k3)]} ................................. ................. + 1/kn *{ mp[b2(1)]+ mp[b2(1)]+ mp[b2(1)]...+mp[b2(kn)]} ]

    Apply MMI and get your answer.

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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

Is there anyone who can help me to find bug in my code? I can't find out why it is showing wrong answer in test case 3. Question no C. submission — https://mirror.codeforces.com/contest/1279/submission/79246638 I have seen codes with same logic got accepted so I am pretty sure my logic is fine.