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

Автор maroonrk, история, 2 года назад, По-английски

We will hold AtCoder Regular Contest 170.

The point values will be 400-500-600-700-800-1000.

We are looking forward to your participation!

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

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

gl! btw 400-500-600 seems challenging!

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

is $$$C$$$ prefix-sum dp?

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

Feeling stupid for messing 7 times on B :)

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

D was very nice.

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

How to do D?

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

B can be reduced to Rectangle Union Area

49545573

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

There's a simpler and faster solution for problem E (the complexity is the same, but without matrix operations).

The solution is the same as the official editorial until the last step. Here we need to calculate the sum for every pair of positions, the probability of them being equal in the LR sequence.

Let's say we fix the two positions $$$x \lt y$$$. Now, what we choose before $$$x$$$ and what we choose after $$$y$$$ doesn't matter. For the part from $$$x$$$ to $$$y$$$, there is a probability of $$$p$$$ that a character stays the same as the previous one, and $$$1-p$$$ otherwise.

If we want $$$x$$$ to be equal to $$$y$$$, then there should be an even number of positions where the character differs from the previous one, so it boils down to the following problem:

There is a $$$01$$$ sequence of length $$$m$$$, where each position is $$$0$$$ with probability $$$p$$$ and $$$1$$$ with probability $$$1-p$$$. Calculate the probability that this sequence has an even number of $$$1$$$. The answer to the original problem when we fix $$$x,y$$$ is the answer to this problem when $$$m=y-x$$$.

Let $$$q=1-p$$$ and a polynomial $$$f(x)=(p+qx)^m$$$, then we need to calculate $$$\sum_{i=0}^m[i\bmod 2=1][x^i]f(x)$$$. Using the well-known trick to split the even and odd coefficient, this number equals to $$$\frac{f(1)+f(-1)}2$$$, as the odd coefficients will be eliminated while the even ones are counted twice. So the answer to this problem is $$$\frac{1+(2p-1)^m}2$$$.

Now back to the original problem, after iterating through all pairs of $$$(x,y)$$$, the answer is $$$\sum_{x=1}^{n-1}\sum_{y=x}^{n-1}\frac{1+(2p-1)^{y-x}}2$$$. Now we fix $$$y-x$$$ first, then we need to calculate $$$\frac12\sum_{i=0}^{n-2}(n-i-1)(1+(2p-1)^i)$$$. This can be calculated in $$$O(\log n)$$$ time after some deduction to the geometric series sum.

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

can anyone explain the approach of A please?

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

    There are only 2 kind of disparities possible :

    ..B...A..
    ..A...B..
    

    To clear disparity of type BA where s[i]='B' and t[i]='A', there are two options to either have sequence AB or BB after the occurrence of BA. Since, we need to minimize our operations we will prefer AB over BB because by doing so we will eliminate two disparities with 1 operation while latter will remove only one disparity.

    To remove BA you can maintain a stack for it whenever you encounter AB pop it and do ans++.

    Now we would still be remaining with some ABs but insufficient number of BA so now we will search for type BB after the last occurrence of BA. Since the BB after the last BA will able to convert all the BAs to BB and do ans++.

    Similarly, do it for AB but now iterate and maintain a stack form the end.

    Here's a link to my submission : (https://atcoder.jp/contests/arc170/submissions/49550689)

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

How is this solution accepted for B? Isn't the time complexity O(n^2) at the least?

#49543170

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

Can someone explain which corner case I missed as I got 2 WAs.

https://atcoder.jp/contests/arc170/submissions/49543465

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

AtCoder, please provide test cases after contest, its very difficult to check all corner cases after contests also

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

When I was thinking of the problem D, I came up with using random.

Distinctly, the N^2 log N algorithm is common.

And after that, I considered using random. In more detail, I ramdomly chose 100 num (I called it as x) and checked if there is j satisfies (a[i],a[j],b[x]) is possible to form a triangle.

My program (https://atcoder.jp/contests/arc170/submissions/49557854) was accepted, but I wonder if anyone could hack it.

My English is not good, please forgive me for some naive syntax errors.

Thanks for your reading!

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

In the editorial of C , it is mentioned that when M >= N — 1 and N >= 2 , the answer is M^c , c -> number of zeroes. I don't think it is quite right. for eg. take S = 00100 , and M >= 5. As per above answer shall be M^4 , but it is actually (M-1)^4. I guess you meant (M — 1)^c ?

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

I finally upsolved A. Damn was it hard !!

I'm disappointed the official editorial don't provide "counter exemple" testcase to understand parentheses trick.

Example:

S:BAAAABBBBA
T:ABBBBAAAAB

I'm also disappointed no code solution is provided. Since ABC335, the editorial are often incomplete, i.e. with textual explanation and solution code.

x: textual explanation.
X: textual explanation + solution code.
--------A-B-C-D-E-F-G
ARC170:-x-x-x-x-x-x-x
ABC337:--------------
ABC336:-------X-x-x--
ABC335:---------X-x-X
ABC334:-X-X-X-X-X-X-X

Complete editorial is essential to upsolve and keep motivation.

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

I realized that in E you can just use Berlekamp directly on the answer and the recurrence even has size at most $$$4$$$...

You can probably pass by calculating the first $$$8$$$ terms in $$$2^n$$$ or even by precalculating this recurrence offline. Now I find it more interesting that so little people ACed this problem

My code: https://atcoder.jp/contests/arc170/submissions/49586277 I was really about to bash the genfunc when I realized that this will just give me $$$O(1)$$$ linear reccurence