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

Автор awoo, история, 3 года назад, По-русски

1860A - Не подстрока

Идея: BledDest

Разбор
Решение (Neon)

1860B - Юбилейные монеты

Идея: BledDest

Разбор
Решение 1 (BledDest)
Решение 2 (BledDest)

1860C - Игра с перестановкой

Идея: BledDest

Разбор
Решение (Neon)

1860D - Сбалансированная строка

Идея: BledDest

Разбор
Решение (Neon)

1860E - Редактор с быстрым перемещением

Идея: BledDest

Разбор
Решение (awoo)

1860F - Вычисляем ПСП

Идея: BledDest

Разбор
Решение (awoo)
  • Проголосовать: нравится
  • +125
  • Проголосовать: не нравится

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

Привет!

По началу казалось что будет тяжело, но я справился решил 2 задачи( мог 3).

Спасибо за соревнование!

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

Pardon me if this is a stupid question, In problem D, after dp is used, the editorial says the answer is in the dp[n][cnt0][need], why can't "need" also be equal to just cnt0*cnt1 instead of (cnt0*cnt1/2) because in 00011 its balanced and the number of 01 subsequences is cnt0*cnt1 so should'nt we also check dp[n][cnt0][cnt0*cnt1].Thanks

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

In problem C, I used the approach of maximum increasing subsequence. If Alice puts the chip on ith number, BOB, in the next turn, will put it to the second smallest number in maximum increasing subsequence, and then Alice has to move to the smallest number in the next turn which makes BOB the winner.

so Alice can only win if the size of the maximum increasing subsequence is 1 till the ith number. so that bob has to move the chip to the smallest number and Alice wins.

I got the wrong answer on test case 2. Please help me to know why this approach did not work. Thanks in advance.

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

    Alice will not win if the length is 1, She'll only put the coin in first move on the i th element. Now Bob won't have anywhere to move that coin to, So Bob wins. Alice only wins if the length of the maximum increasing subsequence ending at ith element has the length 2 : she puts the coin on ith element, then Bob has to move it to the remaining 1 element, then Alice won't have any moves to make further.

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

    Lets take an example:

    arr = [1, 2, 3, 4]
    Expected Answer: 1
    Your Answer: 2
    

    According to your solution position with value 2 and 4 will be lucky.

    But if you see for the value 4, Bob will make a move to 2, Then Alice is forced to make a move to 1, and Bob can't make a move now. So Bob wins.

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

It is now obviuos that this round had a problem with tests for task D. They were weak, tons of wrong greedy solutions got accepted and then hacked. Only an idiot would consider tests of such a quality normal. This is not okay, and I think the least authors owe to contestants is an apology for their sloppy work. Things like this should not be allowed by the community.

P.S.: Dear BledDest, I'm asking, I'm begging on my knees: please, don't make other posts about how wrong being toxic is. Because, as we've seen yesterday, sometimes if the author spends too much time fighting with toxicity in the community, he may not have enough time left to develop good tests for his problems.

P.P.S.: Don't mean to offend anybody. Make love, not crappy tests.

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

There is also a $$$O(n^4/\omega)$$$ approach for D:

Let's say the imbalance score of a string is the difference between the number of 01 and 10 sequences. Then the desired string should have a imbalance score of 0. There are two observations:

  1. You will never operate on a position twice, and you will never operate on two zeros or ones.
  2. By swapping a pair of 0 and 1 at position $$$(p, q)$$$, the imbalance score increases/decrease by $$$2 \times(p-q)$$$, no matter what substring is between the pair.

So you can calculate the imbalance score of the initial string and then do a backpack with bitset. In detail, let $$$S_0$$$ denote the set of position where there are 0s initially, and $$$S_1$$$ the set of position where there are 1s initially, and $$$d$$$ to be imbalance score of the initial string.

By observation 2, the task is now transformed into this: find the minimal $$$k$$$ such that you can select exactly $$$k$$$ numbers from each of $$$S_0$$$ and $$$S_1$$$, so that the sum of the $$$k$$$ numbers selected from $$$S_0$$$ is exactly $$$d/2$$$ greater than the sum of the $$$k$$$ numbers selected from $$$S_1$$$.

https://codeforces.me/contest/1860/submission/219317671

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

it is stored in dp(n,cnt0,need) , where cnt0 is equal to the number of characters 0 in the string s , and need=cnt0⋅cnt12 (because the number of subsequences 01 should be equal to the number of subsequences 10). But our dynamic programming stores the number of changes in the string, and the problems asks for the minimum number of swaps. However, we can easily get it from the dp value. Since the amounts of zeroes and ones are fixed in the string, then the number of changes from 0 to 1 equals to the number of changes from 1 to 0 and we can pair them up. So, the answer to the problem is the half of the dp value.

Can anyone explaine me how need is equal to c0*c1 also how storing string changes helps in calculating answer?Please

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

In problem D, can someone help me how value of dp changes if s[i] is 0/1 ?

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

In problem C, How is it solved using Binary Indexed Tree or Segment tree? What is the logic?

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

What can be the best complexity in problem C, if we would allow repetitions in the array?

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

Can anyone explain the problem D solution?

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

In problem D, is there any way to solve it with recursive dp?

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

In problem D, Is there any way to solve it with recursive dp?

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

The rotating sweep line intuition in F is cumbersome and not so easy to think about. I find the following way to be more easy and intuitive (Well, they are equivalent, but I don't like rotating sweeplines).

Sorting pairs $$$(a, b)$$$ by $$$ax + by$$$ is the same as sorting pairs by $$$a + b\cdot \frac{y}{x}$$$. Now you can replace $$$\frac{y}{x}$$$ with any positive real $$$t \gt 0$$$, and you sort pairs by $$$a + b\cdot t$$$. From now it's obvious, that initially you arrange the pairs lexicographically ($$$t = +\varepsilon$$$), and then gradually increase $$$t$$$, the pairs that are swapped are of kind $$$(a_1, b_1)$$$ and $$$(a_2, b_2)$$$, where $$$a_1 \lt a_2, b_1 \gt b_2$$$ (and the swap is performed for $$$t = \frac{a_2 - a_1}{b_1 - b_2}$$$).

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

Finally new Color(CM).

Video Editorial for Problem D,E:-

https://youtu.be/khVG1JPdR1o

Video Editorial for Problem A,B,C:-

https://youtu.be/wZF5qfvBhuM

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

Explanation for those who are confused in Problem E why the author has not constructed a transposed graph to find out the distance from f -> s :

Let say we are connecting an edge of weight 1 when we are going from dummy node to an index node and an edge of weight 0 from index node to dummy node. When we are finding shortest distance from dummy node to index node then bfs on the normal graph will work. It is obvious.

But when we are finding shortest distance from index node to dummy node then we should apply bfs from the index node. But we can't do that as it will result in O(n^2) complexity. Alternative is that we can apply bfs from dummy node in the transposed graph and find the shortest path for each index node. So the complexity is now reduced.

But it is not necessary to construct the transposed graph. Edges between index nodes are already bidirectional. In transposed graph, from dummy to index we will have an edge weight of 0 now . In the original graph, we are getting an extra edge weight as from dummy to index we are traversing via edge weight 1 and rest all edges in path have the same effect.

So we can use the original distance and reduce it by 1.

Hope it helps !!

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

BledDest Sorry for necroposting. For Problem F, I would like make a clarification to the problem statement by asking what the expected output is given the following test case:

1
4
4 1 )
3 2 (
2 3 (
1 4 )

According to the second paragraph of your problem statement, we may choose $$$(x, y) = (1, 1)$$$ so all the $$$a_i \cdot x + b_i \cdot y$$$ are $$$5$$$ and place them in ()() since it's a tie. However, the sample solution written by awoo above outputs NO instead.

Thanks a lot!

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

1860C - Game on Permutation

Hint1
Hint2

Tutorial

Submission : 237228234

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

C was just an application of the classic LIS problem.

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

easy solution for problem B 352777284 without binary search or brute force which may lead to TIME LIMIT EXCEED.