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

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

Thank you for participating!

1807A - Plus or Minus

Idea: flamestorm

Tutorial
Solution

1807B - Grab the Candies

Idea: mesanu

Tutorial
Solution

1807C - Find and Replace

Idea: flamestorm

Tutorial
Solution

1807D - Odd Queries

Idea: SlavicG

Tutorial
Solution

1807E - Interview

Idea: SlavicG

Tutorial
Solution

1807F - Bouncy Ball

Idea: mesanu

Tutorial
Solution

1807G1 - Subsequence Addition (Easy Version)

Idea: flamestorm

Tutorial
Solution

1807G2 - Subsequence Addition (Hard Version)

Idea: flamestorm

Tutorial
Solution
Разбор задач Codeforces Round 859 (Div. 4)
  • Проголосовать: нравится
  • +20
  • Проголосовать: не нравится

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

It will be good if there exists some more explanation of F. Bouncy Ball Problem.

I am still not able to simulate the movement of ball.

Can anybody else explain it to me?

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

How did the next direction calculated in the problem F?

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

    For each direction, think about how you can transition to other directions.

    Let's say the ball is at $$$(r,c)$$$ with direction $$$DR$$$. There are 3 possibilities:

    1. It hits the corner, $$$r=n$$$ and $$$c=m$$$: Change direction to $$$UL$$$.
    2. It hits the bottom first, $$$r=n$$$ and $$$c \lt m$$$: Change direction to $$$UR$$$.
    3. It hits the side first, $$$r \lt n$$$ and $$$c=m$$$: Change direction to $$$DL$$$.

    Try this for each direction.

    Submission: 198396729

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

Yes Or No Forces

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

Another opportunity to feel ashamed....!!!

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

What is the proof for $$$\text{states} \leq 2mn$$$ in problem F?

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

How do you come up with the solution of G2? Can some experienced people tell me? I tried a lot to solve that problem but was not able to. I read the codes of some AC solutions after the contest but was not able to understand why that worked. Only after reading the editorial, I understood the solution. The people who solved it, did you prove the solution using induction during the contest? How do I develop this skill?

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

problem F why they set vis[n][m][4], i think the ball only vis a pair (x, y) at most 2 times

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

Can any one tell me why my solution 198576200 got tle on test 23. Why not this submission got tle 198142369. I just wanted to know the reason. Thanks in Advance.

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

I solved F in O(n+m) xD!

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

I am very excited for the next div4 contest to be unrated for me.

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

This might be a dumb doubt, but shouldn't the time complexity of E be $$$O(n*log(n))$$$? I mean we are also printing numbers in each query.

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

    replying to a 9 days old comment, but here is your answer.

    Its actually O(n) because you are printing n numbers at first, then n/2, then n/4 and so on....

    and we know n + n/2 + n/4 + .... (infinite sum) = 2 * n

    so the finite sum is between n operations and 2 * n operations, hence its O(n)

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

For problem F, I didn't consider the approach of creating a matrix, such as bool vis[n][m][4] from solution, because I thought it would go over 1GB of memory (25000x25000x4 x 1 byte).

Since this wasn't the case, can someone point me out why?

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

    "It is guaranteed that the sum of $$$n*m$$$ over all test cases does not exceed $$$5*10^4$$$"

    So you can conclude that $$$n*m$$$ is at most $$$5*10^4$$$. You can create that matrix accordingly with the input, vector<vector<vector<bool>>> v(n, vector<vector<bool>> (m, vector<bool>(4, false)));

    I don't know if this code above is the best way to do it, but It seems to work good

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

1807D - Odd Queries Getting TLE

for _ in range(int(input())):
    n, q = map(int, input().split())
    a = [int(x) for x in input().split()]
    sum_of_a = sum(a)
    for _ in range(q):
        l, r, k = map(int, input().split())
        ans = sum_of_a - sum(a[l-1:r]) + ((r - l + 1) * k)
        print("NO" if (ans % 2 == 0) else "YES")
»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In the problem E Why we are subtracted pref[mid]-pref[l-1]

Instead of this why we can't use only pref[mid] ??? Can anybody explain to me ??

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

    Because as you binary search, the value of $$$l$$$ changes, so you are not always summing from the start of the array. You want to compute the sum from index $$$l$$$ to index $$$r$$$ quickly so you can use the prefix sum array since $$$\sum_{i=l}^{r} A_i = \sum_{i=0}^{r} A_i - \sum_{i=0}^{l-1} A_i$$$.

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

2 1 3 8 7 1 10

SUGGESTED ALGO WILL OUTPUT YES IN THIS CASE... BUT THE RIGHT ANS IS NO.....

WHEN YOU GET TO 2 1 3 8 7 1 SITUATION

NO SUBSEQUENCE IS POSSIBLE TO MAKE 10

PLEASE CORRECT ME IF I AM WRONG