ilyakrasnovv's blog

By ilyakrasnovv, 2 years ago, translation, In English

Hello, Сodeforces!

We are very grateful for Your participation in our round.

Thanks to Qwerty1232 for the help with this editorial.

1715A - Crossmarket

Advice #0
Hint #1
Hint #2
Hint #3
Solution

1715B - Beautiful Array

Hint #1
Hint #2
Hint #3
Solution

1715C - Monoblock

Hint #1
Hint #2
Hint #3
Solution

1715D - 2+ doors

Hint #1
Hint #2
Hint #3
Solution

1715E - Long Way Home

Hint 1
Hint 2
Hint 3
Solution

1715F - Crop Squares

Advice #0
Hint #1
Hint #2
Hint #3
Solution
  • Vote: I like it
  • +204
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it +41 Vote: I do not like it

TLE on D T.T

»
2 years ago, # |
  Vote: I like it -35 Vote: I do not like it

Trash contest

»
2 years ago, # |
  Vote: I like it +17 Vote: I do not like it

Wow, such a fast tutorial!

»
2 years ago, # |
  Vote: I like it +75 Vote: I do not like it

One of the best C

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    For experts or higher I guess

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +71 Vote: I do not like it

    I don't think Monoblock's company is having many sales with such a complicated captcha.

»
2 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Thanks for the really nice contest and also the editorial:)

»
2 years ago, # |
  Vote: I like it +18 Vote: I do not like it

Though I couldn't perform as well as I expected, the contest and the problems were interesting :)

»
2 years ago, # |
  Vote: I like it +59 Vote: I do not like it

I think convex hull trick is too complicated for div2 E, please don't add such tasks

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +76 Vote: I do not like it

    You can also do it with D&C dp, I think this was a nice question. You learn these tricks but there aren't many "easy" questions on them because they are generally reserved for harder problems with more observation. This was a simple application and personally I got a nice Aha moment when realising I could use D&C, imo this way you get a chance to build an intuition for them

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +24 Vote: I do not like it

    my hands finally knows about CHT by this task

»
2 years ago, # |
  Vote: I like it +18 Vote: I do not like it

You can also solve E using Divide and Conquer DP because of the square cost function

My submission

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    can you elaborate on the divide and conquer dp?

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      The objective of the D&C was to calculate the minimum distance after a flight(assuming the flight just landed at some point), so you have a set of distances you got from dijkstra in $$$dp$$$_$$$old$$$, then you calculate post flight distance for $$$i$$$, aka $$$dp$$$_$$$new[i]$$$ as $$$min_j (dp$$$_$$$old[j] + (i-j)^2) $$$

      I divided this up into two parts
      $$$min_{j<i} (dp$$$_$$$old[j] + (i-j)^2)$$$
      $$$min_{j>i} (dp$$$_$$$old[j] + (i-j)^2)$$$

      Both of these are what I solved using D&C DP, followed by more Dijkstra to calculate travel via roads

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        nice get the divide and conquer now,

        using the optimal to cut up the array was cool wouldn't have thought of that

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Can you elaborate how to solve one of those partial minimums? I was able to do that only with some crazy math.

        • »
          »
          »
          »
          »
          2 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Let $$$opt[i]$$$ be the index $$$j, j<i$$$ which gave the minimum value of $$$dp[j] + (i-j)^2$$$, then Divide and Conquer DP works iff $$$x < y$$$ implies that $$$opt[x] < opt[y]$$$, which you can see is the case here with some light maths. What you do is, if you want to calculate $$$dp[l]$$$ to $$$dp[r]$$$, let $$$mid$$$ be the middle point, you calculate $$$dp[mid]$$$ and $$$opt[mid]$$$ in $$$O(r-l)$$$, and once you calculate $$$opt[mid]$$$, it reduces the range you need to search for the rest of the elements, then you recursively do this calculate $$$dp[mid]$$$ and $$$opt[mid]$$$ for the segments that are left and right of $$$mid$$$.

          This was very brief but you can read more about Divide and Conquer DP here

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone explain the Convex Hull Trick mentioned in E? I can't figure a way to calculate the minimum for each node without iterating over all other nodes to get $$$d_{new}[v]$$$

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Its a somewhat advanced DP optimisation trick that allows you to optimise dp of the type $$$dp[i] = max_{j<i} dp[j] + cost(j, i)$$$ from $$$O(n^2)$$$ to $$$O(n log(n))$$$ by looking at each of the previously computed DP values as lines with decreasing slopes. You can find tutorial videos online, this is where I personally learned it

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You can also use Li Chao tree (it is just advanced segment tree) Both are data structures that allows you to find minimum/maximum of linear functions' values in O(log(n))

»
2 years ago, # |
Rev. 2   Vote: I like it +40 Vote: I do not like it

For D, another solution is to simply build the answer from left to right, choosing the minimum value of $$$a_i$$$ each time.

To do this, first we need to restrict which bit of each $$$a_i$$$ can be $$$1$$$. This can easily be done by looping through all the condition $$$(i, j, x)$$$:

  • If the $$$k$$$-th bit is $$$0$$$ in $$$x$$$, then it must be $$$0$$$ in both $$$a_i$$$ and $$$a_j$$$.

Let call $$$allowed_i$$$ the number that has all allowed 1-bit of $$$a_i$$$, then we can see that $$$a_i = allowed_i$$$ is a solution to the conditions, and for all solution, $$$a_i$$$ is a submask of $$$allowed_i$$$.

Then we can loop from $$$1$$$ to $$$n$$$ and construct $$$a_i$$$.

For $$$a_1$$$, we want to make it as small as possible, which mean we want each bit to be $$$0$$$, if possible. We can loop through all the condition $$$(1, j, x)$$$ to check which bit of $$$a_1$$$ must be $$$1$$$. Simply, if a bit is $$$1$$$ in $$$x$$$, but $$$0$$$ in $$$allowed_j$$$, then that bit must be $$$1$$$ in $$$a_1$$$.

It's easy to see that after this process, the best $$$a_1$$$ is just all the forced bits. We can then loop over the conditions $$$(1, j, x)$$$ and force the $$$1$$$ bits on $$$a_j$$$. Just repeat this to get the answer.

You can see my implementation here: 169201529. (Please excuse the weird syntax, I'm experimenting with it).

My implementation is $$$O(n + mlog(m))$$$ due to sorting the initial conditions, but $$$O(n + m)$$$ is achievable as we can do the work for all bits at once in this solution.

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Hello! Could you please tell the reason for contest extended? As for me, nothing was wrong, so I'm just curious. Thanks!

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    During contest many contestants expirienced issues with Bad Gateway

»
2 years ago, # |
  Vote: I like it +3 Vote: I do not like it

In problem C, Can Somebody explain why to add number of segments in initial answer? i.e After adding the number of subsegments, we get the answer: 6⋅72=21,21+14=35.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    consider any subarray with no joints ,the answer will be one; if there are x joints in a subarray, the beauty value is actually x+1; so the number 21 that you see is actually number of segments when we consider them without joints and the we add 14 to compensate for all the joints that could be considered;

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Video Solution for Problem C and Problem D.

»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Hello, Can someone please explain why this failed (Problem B)? 169134990

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Your solution failed because: 1. The lower bound for s would be b * k (handled properly) 2. The upper bound for s would be b * k + n * (k — 1) (your code does not handle this properly).

    As, after setting first element to b * k, you can still add k — 1 to each element of the array.

    Counter Test Case: 1 2 3 1 6

    Correct Answer: (5, 1) or (4, 2) Your Code output: -1

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi, anybody can explain, why my solution is wrong? WA test 4 https://codeforces.net/contest/1715/submission/169168903

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Hi! It seems like you forgot that if the ith bit of (a | b) is equal to 0, then the ith bits of both a and b must be equal to zero.

»
2 years ago, # |
  Vote: I like it +36 Vote: I do not like it

An alternative randomized solution for Problem F:

Disclaimer: My solution fails on test 65, but I think it is probably an implementation error. Please correct me if this solution is just completely wrong.

The basic idea is to draw a lot of rectangles of the width of the field. Draw the first one at $$$y=0$$$ with height $$$1 \cdot \varepsilon$$$. Draw the next one at $$$y=1 + \varepsilon$$$ with height $$$2 \cdot \varepsilon$$$, and so on, each one exactly $$$1$$$ apart and $$$1 \cdot \varepsilon$$$ taller. We choose $$$\varepsilon$$$ as a very small number.

Since we have to draw one polygon we can just connect all rectangles on one side.

The square can only intersect one rectangle since they are each $$$1$$$ apart. We don't want any rectangle to only partially intersect with the square, so we offset everything by a random number between 0 and 1. This makes a partial intersection very unlikely since the height of our rectangles is very small.

With the answer to our query we can determine which rectangle the square intersects with and we know the $$$y$$$-coordinate is within the interval $$$[y_{rectangle}-1, y_{rectangle}]$$$. To determine the exact coordinate we can just query this interval and calculate $$$y$$$ with the intersection area.

We can repeat this for $$$x$$$ to get the answer in

Unable to parse markup [type=CF_MATHJAX]

queries.
  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    My solution is similar to yours. But I chose to randomly set a small value for the width of each rectangle, and fixed the interval between each rectangle to 1.

    It passed all the test points. Here it is.169490864

    I'm so sorry that I am poor in English.

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anybody tell why my solution for D doesn't pass? It has same complexity. O((n + m) * log(x)).

Here is solution: 169156511

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I have not gone through your code, but I can tell you the Test case where it fails Counter Test Case: 2 2 1 2 7 2 2 6

    Correct Answer: 1 6 Your code output: 0 6

    I hope this would help you :)

»
2 years ago, # |
  Vote: I like it +94 Vote: I do not like it

The evolution of $$$Div2$$$ $$$E$$$

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

can someone tell the rating of the C problem ?

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    I guess somewhere around 1700...

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      ok thanks, it is harder than the usual Div2 C problems

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Agree.I felt the same XD

        • »
          »
          »
          »
          »
          2 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Excuse me, but I'm just curious about the meaning of "XD".

          • »
            »
            »
            »
            »
            »
            2 years ago, # ^ |
            Rev. 2   Vote: I like it 0 Vote: I do not like it

            see the XD by rotating your device, it is text form of laughing emoji (this one)

            Similar to ;) or :)

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I think C was reasonable for Div 2 since the only major (intellectually) hard part was figuring out how to compute the cost at the start. Transitions between queries were really simple (albeit long) and didn't require much thinking.

»
2 years ago, # |
  Vote: I like it +35 Vote: I do not like it

Oh no! I got the solution of F during the contest, but it only cost 2 steps.So I didn't dare to write:(

»
2 years ago, # |
Rev. 2   Vote: I like it +24 Vote: I do not like it

A solution I thought of for E was to use a segment tree, what you would do is take the old distance and add $$$i^2$$$ to each $$$a_i$$$, doing that and taking the minimum of the array gives the answer for $$$i = 0$$$, then for moving forward from $$$i-1$$$ to $$$i$$$, you add the AP -1,-3,-5.. To the suffix and ...5,3,1 to the prefix — essentially adjusting the square terms we added. For this we of course need a segment tree that can add an AP to a range and take the minimum of all elements, can anyone confirm if that's possible? If it is can you point me to some resource?

»
2 years ago, # |
Rev. 3   Vote: I like it +5 Vote: I do not like it

D does not require any graph theory knowledge at all.

Initially, there are $$$30n$$$ unknown bits.

We can do a first pass over the queries to find all bits $$$p$$$ and $$$q$$$ such that $$$p \mid q = 0$$$, which means $$$p = q = 0$$$. These are the only bits that must be 0 in order to satisfy the statements (you can hypothetically set all remaining bits to 1 and this will satisfy the statements, but likely will not be lexicographically least).

Then we can do a second pass over the queries to find all bits $$$p$$$ such that $$$p \mid 0 = 1$$$ or $$$p \mid p = 1$$$, which means $$$p = 1$$$. The former can arise due to forced 0 bits from the first pass, while the latter can arise from statements where $$$i = j$$$. These are the only bits that must be 1 in order to satisfy the constraints (though you can't simply turn all remaining bits into 0 this time, since our remaining equations have the form $$$p \mid q = 1$$$).

With the fixed bits out of the way, we can greedily clear all non-fixed bits of $$$a_1$$$ to 0. If any of these bits were involved in an equation of the form $$$p \mid q = 1$$$, then the other bit in the equation becomes fixed to 1 to satisfy it. We can then repeat for $$$a_2$$$ and so on.

Runtime: $$$O(m + n)$$$, with a constant 30 iterations for everything.

My Submission: 169185957 (I checked for $$$i = j$$$ and $$$p \mid q = 0$$$ while reading the statements)

»
2 years ago, # |
Rev. 2   Vote: I like it -62 Vote: I do not like it

E is trash

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

About C, It confuses me that where n*(n+1)/2(in the tutorial is 6*7/2)comes from?

  • »
    »
    2 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    In my opinion, it is easier to have an initial array filled with the same number. The initial answer is $$$n \cdot (n+1)/2$$$ since that is the number of subarrays, and each subarray will have an awesomeness of 1. After that, we only have to know how to handle the changes after each operation.

»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

when i looked at my submission after contest, i was surprised when i saw wrong answer Statement not true: (i, j, x) = (78387, 31267, 38016256)

after that i used assert to check if the limit on every bit is satisfied. to my surprise, the assert doesn't happen.

can anyone tell me why? the submission id is 169192815

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There are $$$q$$$ statements, but your solution reads $$$n$$$ statements only.

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      ohhhhhh thanks!!

      when i noticed it, i really laughed out very loud

»
2 years ago, # |
  Vote: I like it +8 Vote: I do not like it

In problem E, could anyone explain the Dijkstra part mentioned in the editorial? How to transfer from "ending with air travel" to "ending with a usual edge"?

  • »
    »
    2 years ago, # ^ |
    Rev. 5   Vote: I like it 0 Vote: I do not like it

    My solution of E:

    Let's just use Dijkstra algorithm with only roads. Now repeat next thing k times:

    For each v:

    dp[new_layer][v] = min(dp[previous_layer][v], minimum_of(cost_of_flight + dp[previous_layer][from]))

    Run Dijkstra on updated distances

    Answer for vertex i after k repeats is dp[k][i]

    Submission using Li Chao tree for finding minimum_of(): 169168040

    • »
      »
      »
      2 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      What does it mean to "Run Dijkstra on updated distances"?

      How is it different from normal Dijkstra?

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        It is not any different. You have some precounted distances, use them instead of INF you use usually and run usual Dijkstra

»
2 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Great contest! I like A,C and F personally.

»
2 years ago, # |
  Vote: I like it -25 Vote: I do not like it

The system tests of problem D are too weak. Will it be retested?

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I used a slightly different approach to D that didn't require a seperate pass for each bit:

  • Create a weighted graph
  • For each vertex AND together the weights of all its neighbouring edges. This tells you what bits can be set for that vertex. Call this the available value for the vertex.
  • Now go through the vertexes in order. If a vertex is its own neighbour then that gives you its value. Otherwise, OR together values for each edge:
    • If the edge goes to a lower numbered vertex, include those bits that are required by the edge but are not included in the solution for the other vertex. This can be calculated as (Edge weight) AND NOT (Other vertex value)
    • If the edge goes to a higher numbered vertex, include those bits that are required by the edge but are not available for the other vertex. This can be calculated as (Edge Weight) AND NOT (Other vertex available value)

This gives each vertex its smallest possible value subject to the values given to previous vertexes, so gives the lexically smallest possible sequence of values.

See my solution 169149168

I think one could create a similar solution without creating a graph by doing two passes through the data, which might be more efficient.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    My last comment is wrong. On the second pass one needs to go through the array values (vertexes) in order, and to know the final values of all lower numbered adjacent vertexes before calculating the value of current vertex, so this needs full adjacency information (i.e a graph).

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

The time complexity between 169232632 and 169236193 is the same. The only difference is I scanned in increasing order instead of decreasing order. I wonder whether it is a trick to cut down time.

»
2 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

This solution is easy for problem A.

»
2 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

In problem E,

I'm facing a weird issue, when I initialize the distance to all the arrays with >= 1e14, it gives WA on test case = 37, otherwise, it passed all the test cases.

https://codeforces.net/contest/1715/submission/169246634

https://codeforces.net/contest/1715/submission/169246972

Can someone help me?

All that I'm changing between the two submissions is for(int i=2;i<=n;i++) dist[i] = ll(1e14);

  • »
    »
    2 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    [Removed, as it was an in invalid test case].

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The test you provided isn't valid because $$$k$$$ must be at least $$$1$$$. In fact, when $$$k$$$ is at least $$$1$$$, taking a direct flight from $$$1$$$ to $$$n$$$ is always an option, so the answer is bounded by $$$(n - 1)^2 < 10^{10}$$$.

  • »
    »
    2 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    My guess is that you overflow in your HullDynamic class. ks and bs can both overflow int, and so multiplication might overflow long long:

    (x->b - y->b) * (z->m - y->m)

    UPD: Changed long longs to int128 in your HullDynamic class, AC now: 169286182

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why in authors code of C.Monoblock, they used (n — (i + 1) + 1) instead of (n-i)? As both will give same answer. Why to use (n — (i + 1) + 1). (In for loop)

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What's that in C++ code for E?

for (int i = 0; i < k; ++i) {
        for (int i = 1; i < n; ++i) {
        }
        for (int i = 0; i < n; ++i) {
        }
    }
»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone help me find out why my solution didn't pass for D ?

Here's my solution: for each index 1<= i <=n, let's find the bits that must be set to zero. Now let's iterate over the array starting from the last element, for each element we will only consider the statement that include another element with smaller index. For each statement that include that element, let's set to 1 all of the bits that are set to 1 in the OR value and can be set to 1 in the current index, the other bits will be set to 1 in the other element since we can't set them in the current one.

Here is a link to my submission: https://codeforces.net/contest/1715/submission/169171341

Any help will be more than appreciated.

  • »
    »
    2 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Simple counter:

    3 2
    1 2 1
    2 3 1
    

    Your code gives 0 1 1, answer should be 0 1 0.

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem F: Life will be harder if the query polygon must have all of its points lying inside the field. (This is the problem statement came from my misunderstood :)).

»
2 years ago, # |
  Vote: I like it +13 Vote: I do not like it

rockstar_an is the best, thanks to him I'm an Expert.

PS : He is my dad :)

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem F is brilliant! Liked it very much :)

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone help me find out why my solution didn't pass for D ?

I think I have written as what have been talked in blog. I have tried to fix it, but I failed.

My submission:169346279

»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Can someone tell me why my code for problem D is failing? here's the code: https://codeforces.net/contest/1715/submission/169397612

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I disagree with Advice #0. You should always consider risk of wasting time on implementation of solution. And thinking about proof and trying to prove may save you from that.

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For those who 1715E - Long Way Home for some reason don't understand why this thing can be applied here: within min first square component may be considered as parameter and second square term can be extracted from min because it's being constant in query.

»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Could anyone help me find why this submission https://codeforces.net/contest/1715/submission/169450718 which is O(32(m+n)) gets TLE but https://codeforces.net/contest/1715/submission/169452067 which could be O(32 * 32(m+n)) passes? The only difference is that I changed from a two-dimension vector to one-dimension vector, where bit information are added in edges instead of one-bit-one-graph. I have been thinking for the whole night. Thx...

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

In author solution for problem E why is it: while (ll.size() >= 2 && l.intersect(ll[ll.size() — 2]) <= x.back())

and not: while (ll.size() >= 2 && l.intersect(ll[ll.size() — 2]) >= x.back())

won't the authors solution remove lines from the Convex Hull that actualy need to be in it.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Figured it out.. brain fart

    We are searching for Min not Max .

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why does my solution for Problem D give TLE, pls someone explain.172482735

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Interestingly, D has similar idea to https://codeforces.net/problemset/problem/1594/D, but you have to do it 30 times

»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I solved problem C with segtree
https://codeforces.net/contest/1715/submission/215391566
I solved a harder problem actually, I can query any segment and find its required value.

  • »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There is a small typo in your template, it's "WEIRD" not "WIERD". Please fix it as it might cause denial of judgement verdicts.