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

Автор PrinceOfPersia, история, 8 лет назад, По-английски
Tutorial is loading...

Writer: PrinceOfPersia

Tutorial is loading...

Writer: PrinceOfPersia

Tutorial is loading...

Writer: PrinceOfPersia

Tutorial is loading...

Writer: PrinceOfPersia

Tutorial is loading...

Writer: PrinceOfPersia

Tutorial is loading...

Writer: Reyna

Tutorial is loading...

Writer: PrinceOfPersia

Разбор задач Codeforces Round 459 (Div. 1)
Разбор задач Codeforces Round 459 (Div. 2)
  • Проголосовать: нравится
  • +92
  • Проголосовать: не нравится

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

Bonus question for Div1B: try to solve when sigma can be of size of m.

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

I have a (maybe simpler and elegant?) solution for div1 A.

How would you solve this if no question marks were involved? Well, this is a standard problem. You iterate through the possible substrings and keep a score which starts from 0, which represents how many open brackets we have. Whenever you iterate over a '(', you add 1 and when you iterate over ')', you subtract one. The string is valid iff at the end the score is 0 and at no point during the iteration was the score negative.

For the problem at hand, we do the exact same thing, except we keep one more counter, say qmarks, which represents the number of question marks so far. Obviously, when we iterate over '?'. we increment this counter. Also, if at any point of the iteration we have qmarks > score, then at least one of the question marks has to be an open bracket (if they were all closed brackets, we would have negative score, which is illegal). Therefore, if this situation occurs, increment score and decrement qmarks.

At the end, a substring is legal iff its length is even and qmarks >= score (we can use question marks to close off all remaining open brackets).

Seems simpler than the solution in the editorial (and also doesn't use additional memory, if that's relevant).

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

Solution #2 for problem D is just beautiful!

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

Div 1 E : "First two variables can be calculated using aho-corasick and segment tree." Can someone explain how to do this? Thanks in advance.

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

How can i solve div2 C with dp?

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

I hope someone can answer my confusion...To Div2 D,I still can't understand the rightness of the editorial.Can this ensure that both players play optimally?

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

Could anyone please tell me what is sigma in 917B editorial?

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

Can someone please explain more precise how to make the the dp with matrix multiplication on Div1C/Div2E? Especially how to construct the matrix to be multiplicated and the initial step of the dp? I have tried to mulptiply the matrix m[i][j] as cost to go from state number i to state number j, but I couldn't find the recurrence

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

In E do you even build suffix trees for every si and ti(or just one big suffix tree)? And if you do, how to get position in small tree from position in big tree?

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

    In my submission (343647) I only build two big suffix trees explicitly.

    In the centroid decomposition I find for each query one node in each of these 'big trees'. After the centroid decomposition I preprocess one of the suffix trees, finding for each of the queries the last node in the suffix tree that is an ancestor of the node from the centroid decomposition and is a suffix of the special word for the query (which is probably what you call 'the position in the small tree', see wlast, oldwlast and qstidx in my code).

    Also at the same time I construct for each suffix of a special word the range in the inorder traversal for that special word that corresponds to the subtree (which is similar to an euler tour of the 'small trees', see bwlid and bwrid in my code).

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

I think problem E can be solve in O(n^2/32)

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

Div1 Problem D dp[u][us][ue] × dp[v][vs][ve] × N × us why N is in this expression? and what N is?

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

In DIV1.B shouldn't the editorial have c <= int(ch(v, x) - 'a') ? As it was given should be greatern than or equal ...

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

namelessgugugu has a $$$O(n^2)$$$ solution to div1D orz

upd: Oh maybe there are lots of them. ignore this