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

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

1767A - Разрежь треугольник

Идея: BledDest

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

1767B - Башни из кубиков

Идея: BledDest

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

1767C - Посчитайте бинарные строки

Идея: BledDest

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

1767D - Плей-офф

Идея: Neon

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

1767E - Algebra Flash

Идея: BledDest

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

1767F - Два поддерева

Идея: shnirelman

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

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

I have become an Expert thanks to this contest! Great D by the way.

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

In problem A, since the first line is empty. I read it as a string and never bothered to use it. It WA'd. This is my submission 185477892 . After the contest, I didn't even bother to read the first line and used the same code as above and it got AC. I am not sure why and could use some help.185647398

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

    cin >> [whatever] doesn't work as you think. The input data is split into tokens: a token is a sequence of characters. Tokens are separated by whitespaces (incl. normal spaces and newline characters). Doing cin >> [whatever] reads the next token* and tries to convert it into the type of the variable. Doing cin >> [whatever] always skips over any spaces and newline characters. Thus, your cin >> s reads the first integer into your string, messing up the values. In order to read a full line into a single string (including all spsces, but not the newline character) you need to do the following:

    string s;
    getline(cin, s);
    

    *doing cin >> [char] only reads the next character, but it still skips whitespaces.

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

I will have time to grow old before the moment when I completely read, understand and solve the problem F... The longest editorial I've ever seen

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

I think the overall complexity of attached solution of E is $$$O(2^{m/2} \cdot m)$$$

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

problem A-E video Editorial for Chinese:

BiliBili

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

Firstly, let's prove that the order of characters in s is interchangeable Can anyone discribe it more widely. why it is happend.i can't visualize this.

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

Problem A:

...and one of the resulting parts becomes a rectangle.

It never becomes a rectangle, rather it becomes a quadrilateral.

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

Please make the editorial more understandable.

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

Please make the editorial more understandable.

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

Most of solutions and tutorials with "mask" are pretty hard to understand.

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

This editorial was hard to understand, please make it easier to understand next time

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

can anyone explain the problem D

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

There is an alternative solution for 1767E - Algebra Flash not using meet-in-the-middle, but employing an additional observation. I suspect that it works in $$$O(2^{m/2}*m)$$$ and system tests validate this, but I could use someone's help for a complete analysis.

A general idea is to activate every color in the beginning and deactivate colors one by one — well, actually two for one (at least). Firstly, we look at the lowest unselected color — call it $$$v$$$. Two options — either make it true (Deactivated) or false (Leave as activated).

First case: we make $$$v$$$ true. Then let's look at its neighbors. If neighboring color $$$u$$$ comes before $$$v$$$ $$$(u \lt v)$$$, this means we already assigned it some color. Otherwise we still didn't decide on color of $$$u$$$ and have to make it false (Because $$$v$$$ and $$$u$$$ cannot be deactivated simultaneously due to the same reasons as described in the editorial).

Second case: we make $$$v$$$ false. There is an important observation to use: If $$$v$$$ is false and all of its neighbors are false too, such color selection cannot be optimal.

Proof

Now, when we set $$$v$$$ to false, at least one of the neighbors must be set to true. So let's select that neighbor and then apply a known procedure for true vertexes (mark its neighbors as false)

Partial proof of complexity.

Since we remove at least 2 vertexes at each state, the maximum depth of recursion is at most $$$m/2$$$. Also, at each state, we have two choices: either to make the lowest color $$$x$$$ true or false. In case of making $$$x$$$ true, we create at most one new state.

In case of making $$$x$$$ false, we select $$$x$$$'s neighbor $$$y$$$, which we mark as true. The number of such neighbors can be up to $$$m$$$, but let's look at each generated state individually. The state with $$$x$$$ false and $$$y$$$ true is a repeated state, which we will also cover when $$$y$$$ will be the lowest unselected color. How many times such states are visited — is something that I need a help with.

If we apply some clever memoization — then the complexity is for sure $$$O(2^{m/2}*m)$$$, but even without memoization the solution passes the System Tests quite confidently.

Note: There is an edge case to look at when marking non-deactivatable colors as false.

Submission: 189735982

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

In problem F, in the first solution, why do we need to separate queries into light and heavy? Help, please.

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

can someone share the n^2 approach for problem C.

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

    n^2 solution: Code

    • dsu[i] = set no in which ith element belongs, the elements in a set must exist in same state (0 or 1) as they're connected with a[i][j] = 1.
    • c[i] = position of the nearest index j such that s[i] to s[j] must have at least 2 diff elements
    • same[i][j] = number of ways elements from i to j would be same
    • dp[i] = number of binary strings considering only rules till 0 to i
    • Hopefully, you understand
»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can someone write the time complexity of problem [problem:1767D]D?

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

You can reduce $$$E$$$'s complexity to $$$O(2^{\frac{m}{2}} + n)$$$ by transforming the problem into finding the maximum independent set of deactivated colors (excluding the colors at platforms $$$1$$$, $$$n$$$, and any colors that are adjacent to each other in the list of platforms). Then you can change the maximum independent set problem into finding the maximum clique of the graph's complement and apply the same sort of memoization as in this problem: https://codeforces.me/contest/1105/problem/E. Or it can be done in $$$\approx O(1.38^m)$$$ with this algorithm.