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

Автор Lewin, история, 7 лет назад, По-английски

Here's the tutorial. Code can be found in this link (more will be added there soon): https://www.dropbox.com/sh/xwxn3zrl1icp3i2/AACtYSdYH0KlTEdVgCFFgPrYa?dl=0

Zoning Restrictions Again
Double Matrix
Hide and Seek
Chladni Figure
Thanos Nim
Palindrome XOR
Rainbow Coins
Zigzag Game
  • Проголосовать: нравится
  • +117
  • Проголосовать: не нравится

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

Peace on you :) Thanks a lot for this Amazing contest ever at least for me :)

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

E was cool, D was very easy (IMO).

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

Nice Proof of Greedy Solution of B , how to solve B using dp (just for curiosity)

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

The problems of this contest was good. :)

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

Sadly I didn`t do my best at this contest, but the problems were really good!

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

My solution for E only used 4 queries.

https://codeforces.me/contest/1161/submission/53759655

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

Can anyone help me with the B. If aij<=bij how does it ensure that there will always be a correct solution. Suppose aij<=bij and aij+1<=bij+1 but aij>aij+1 and bij>bij+1. Then even if the configuration is valid there can't be any solution.I couldn't understand it. Please help me with it.

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

Great contest (Y)

Wondering how everybody answered Thanos nim. Had a hard time figuring what was the insight for the game :)

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

Lol, no test in div1b had n = 83160 or something close to a highly composite number. My code takes like 8 seconds on n = 83160, m = 200000 and random values of segments (this generator). The highest number of divisors seems to be 48 on 51450 when it could've been 128 on 83160.

Maybe such a test could be added to a testset?

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

I didn't fully understand why in Div. 1 — B we can simply check for the divisors of n. Could someone try to explain it a bit better or with an example ?

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

    Let's suppose that image is rotationally symmetrical and image consist of p identical blocks. Then every block has length of n/p. Then if we rotate image by n/p units, the new image will be the same as the original one. Now we can brute force the value p among the divisors of n and check if the rotation i + n/p is correct.

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

    Let a segment be [a,b] when we rotate it by k it gets [a+k, b+k] to be symmetrical there should be a segment [a+k, b+k] which after rotating will move to [a+2k, b+2k] or we can say that all possible values can be [(a+xk)%n, (b+xk)%n].

    r = (a+xk)%n = a+xk-qn

    xk — qn = r — a

    Use bezout identity euqation has solution if r-a is c*gcd(k,n) or r = a+c*gcd(n,k).

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

I recieved a system message that the solution of my first question Div2A Zoning Restrictions significantly matches with that of someone named MetaFish, but I even don't know the person and didn't use Ideone like things by which code can be shared. It may be just a pure coincidence as doing first question there are huge chances of matching the code, so I want to clarify this as it was written in message to comment on the post that I did code on my pc and then using browse submitted it.

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

Actually KMP can solve D by regarding the original and rotated images as two strings and match them together. Time complexity can reach O(m) (use the correct way of vector comparison).

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

Can anyone explain E to me ? "The main claim is that if a player is forced to reduce the minimum number of stones over all piles, then they lose."

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

I am not being able to understand the question of Div-2 (C) Hide and Seek... please someone explain me the question??

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

There is a bruteforce solution for B that works in O(nm * nm) time https://codeforces.me/contest/1162/submission/53760985

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

In 1147C - Thanos Nim

Solution

I didn't get this, suppose the piles are 1,4,4,4 how can we reduce (n/2 = 2 among 4,4,4 piles) to 1,1, It's said that they must be reduced by a different amount??

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

Can someone provide proof in Problem D that k must be a divisor of n?

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

    [Deleted]

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

    Well, I used two facts to prove it.

    1. turning by $$$k$$$ will yield the same result as $$$2k$$$, $$$3k$$$ and so on;
    2. turning by $$$n$$$ will obviously put the circle in the same position it was initially.

    Thus there exists some $$$t$$$ such that $$$tk = n$$$, $$$k$$$ is a divisor of $$$n$$$.

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

    Let the minimum value to do a symmetrical rotation be $$$k$$$.

    Then for any $$$t$$$, such that $$$t \% k == 0$$$, $$$t$$$ will produce a symmetrical rotation too, and generally rotating by $$$t$$$ is the same as rotating by $$$t\%k$$$.

    It's obvious that turning by $$$n$$$ produces a symmetrical rotation.

    Let $$$n \% k != 0$$$, then that means that $$$n \% k$$$ produces a symmetrical rotation. But $$$n\%k \lt k$$$, hence this statement contradicts the first one.

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

    Start numbering from zero,instead of 1

    If a,b moves to (a+k)%n,(b+k)%n.Then (a+k)%n,(b+k)%n will move to (a+2*k)%n,(b+2*k)%n and so on,but there should be a (a+k(q-1))%n,(b+k(q-1))%n,which will move to a,b in next step.

    so, (a+kq)%n=a

    a+kq=dn+a

    kq=dn

    if k is not divisible by n,then it should definitely be divisible by nd.

    q can be at max n.

    SO,d cannot be greater than k.

    So if k divides nd,then k/d should divide n.

    In short if there is a solution with k not divisible by n,then there will definitely be another solution with k1 less than k and k1 divisible by n.

    Try this test case

    7 7

    0 2

    1 3

    2 4

    3 5

    4 6

    5 0

    6 1

    K=2 is a solution,but k=1 is also a solution

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

Can someone please explain 1147B — Chladni Figure string solution.

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

    If for some k, you rotate all segments by k units and you get the same figure back then it is also possible for 2*k, 3*k ......so on. Now you can get the same figure back when k=n. So k must be a divisor of n. Any number under 10^5 has around 100 divisors at max, so you have to check for them only if such a k exists or not

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

Problem B DIV 1

"We can do this by iterating through all segments (a,b), and checking that (a+k,b+k) is a segment (the endpoints taken modulo n if needed)."

How can we check that (a+k,b+k) is a segment in o(1)? Tutorial says that "this gives an O(nm) solution".

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

Can anyone help me? I'm trying to implement a z-algorithm on 'Chladni Figure' problem and i get wrong answer on test 3 saying the output was "yes" and the correct answer is "no" and when i try it myself it shows the correct answer. What is the problem?

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

I am not getting the tutorial of Chladni Figure with fastest approach. please help!

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

In ques:- Palindrome Xor can someone tell me how to take care of case when smaller no. becomes 0 as we are not allowed to take no. equal to zero.