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

Автор rahulgoel, история, 23 месяца назад, По-английски

1691A - Нет нечетности!

Video Editorial
Idea: amul_agrawal
Problem Setting: menavlikar.rutvij JadeReaper rahulgoel amul_agrawal
Editorial: menavlikar.rutvij rahulgoel
Video Editorial: rahulgoel

Hint 1
Hint 2
Solution
C++ Code

1691B - Обмен обувью

Video Editorial
Idea: amul_agrawal
Problem Setting: rahulgoel menavlikar.rutvij JadeReaper
Editorial: menavlikar.rutvij rahulgoel
Video Editorial: JadeReaper

Hint 1
Hint 2
Solution
C++ Code

1691C - Сумма подстрок

Video Editorial
Idea: amul_agrawal
Problem Setting: rahulgoel amul_agrawal
Editorial: amul_agrawal rahulgoel
Video Editorial: amul_agrawal

Hint 1
Hint 2
Solution
C++ Code

1691D - Максимум не меньше суммы

Video Editorial
Idea: amul_agrawal
Problem Setting: fangahawk amul_agrawal rahulgoel keyurchd_11
Editorial: fangahawk rahulgoel
Video Editorial: fangahawk

Hint 1
Hint 2
Solution
C++ Code

1691E - Число групп отрезков

Video Editorial
Idea: amul_agrawal
Problem Setting: akcube keyurchd_11 rahulgoel amul_agrawal
Editorial: akcube rahulgoel keyurchd_11
Video Editorial: akcube

Hint 1
Hint 2
Hint 3
Solution
C++ Code

darkkcyan's solution without using sets in python.

Python code

TheScrasse's $$$nlog^3n$$$ solution for E using Boruvka and Mergesort tree :D

Code

1691F - Дерево и k-подмножества

Video Editorial
Idea: ltc.groverkss
Problem Setting: ltc.groverkss amul_agrawal rahulgoel
Editorial: rahulgoel
Video Editorial: rahulgoel

Hint 1
Hint 2
Hint 3
Solution
C++ Code
  • Проголосовать: нравится
  • +141
  • Проголосовать: не нравится

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

It was a very nice contest.

PS: O(n) Solution for D

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

    here's my python DP O(n) solution for D O(n) DP solution for D

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

      An even more simple o(n) solution for D

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

        Can you explain how this works? It looks much simpler than what i did. Also, how did you get this thought process.

      • »
        »
        »
        »
        23 месяца назад, # ^ |
          Проголосовать: нравится +29 Проголосовать: не нравится

        hey your code is giving "yes" for the input 10 -6 1 1 -6 10 but answer for this case should be "no"

        week testcases !!!!

        Testers please look

        • »
          »
          »
          »
          »
          23 месяца назад, # ^ |
          Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

          I tried something like sliding window but seems the testcases are weak hence it passed.

          • »
            »
            »
            »
            »
            »
            23 месяца назад, # ^ |
              Проголосовать: нравится +2 Проголосовать: не нравится

            yes many other participants also did similar thing and their submission is passed in system testing.

            • »
              »
              »
              »
              »
              »
              »
              23 месяца назад, # ^ |
                Проголосовать: нравится +1 Проголосовать: не нравится

              I also saw some submissions with O(n*n) complexity, but still accepted very weak test cases.

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

        It gives WA when using this algo

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

    My friends solution for D O(N), a <= the input array prefix_a <= prefix sum a[0] + ... + a[i] = prefix_a[i]

    a_ngt <= next greater value pre_ngt <= next greater value

    now for i in 0 to n-1,

    if pre_ngt[i] < a_ngt[i] return false;

    why because for subarray starting at index i and ending at pre_ngt[i], will have max value a[i] and a[i+1] + ... a[pre_ngt[i]] >0, since pre_ngt[i] is the index where prefix_a[ ngt] > prefix[i].

    Then just reverse the main array A and apply the same check. You can check his implementation over 159050281.

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

    Explaination about the solution using next element max index
    https://codeforces.com/contest/1691/submission/159050281
    To check, we try to find if there exists a subarray l..r so that max(l..r) < sum(l..r)
    Let i is the index of maximum value in the subarray
    sum(l..r) = sum(l..i-1) + arr[i] + sum(i+1..r) > arr[i] <=> sum(l..i-1) + sum(i+1..r) > 0
    So for each index i, we check if there exists index r>i so that max(i+1..r) <= arr[i] and sum(i+1..r) > 0, then reverse the array and do the same
    For each index i, to find r so that max(i+1..r) <= arr[i], we use next element max index. If next element max index of i is j, then all element from i+1..j-1 <= arr[i]
    sum(1+1..r) > 0 <=> sum(0..r) — sum(0..i) > 0 <=> sum(0..r) > sum(0..i), so we use next element max index on the prefix sum. If next element max index of the prefix sum at i is r then sum(i+1..r) > 0
    If r<j, there exists a subarray not satisfying the constraint.

»
23 месяца назад, # |
  Проголосовать: нравится -155 Проголосовать: не нравится

What F*ckhead created problem C ?

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +29 Проголосовать: не нравится

    First of all, that language is not ok in a public forum. Secondly, accounts of setters are given with each problem.

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

    says the guy who only solves A and B in contests (NO OFFENCE)

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +12 Проголосовать: не нравится

    A very smart guy.

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

    I was really panicking when I saw no error in my C, but just after the contest I saw the test case finally and I mishandled the case with only single '1'. Really such problems test our patience, but you can use it to improve your temperament.

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

I think problem E can be solved using segment tree, is that right?

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    Yes

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +15 Проголосовать: не нравится

    Yes, the thing you can do is pretty similar to my solution. If two segments [l1; r1], [l2; r2] do intersect, it means that either:

    1. l2 <= l1 <= r2
    2. l2 <= r1 <= r2
    3. l1 <= l2 <= r2 <= r1

    Lets forget about the third case for a moment. We take, for example, red segments. Then we make two arrays. One of them stores right ends of red segments. Another one stores left ends. We sort the arrays.

    Then we iterate through blue segments [l; r] and for each we find all the right ends l <= r1 <= r and all the left ends l <= l1 <= r. It's obvious that all the l1s make a continuous segment in left ends array. The same thing works for the right ends. That means that we can find the smallest l1 (r1) and the greatest one. Then we want to unite all the segments between them and the blue segment we are looking at. Using the seg tree, we will mark whether the segment should be united with the previous one in left (right) ends order.

    Back for the third case, it's obvious that l1 <= l2 <= r2 <= r1 also means that l1 <= l2 <= r1. So to count all the intersections from the third case, you basically just need to use the solution above two times with different colors.

    P.S. The part with the seg tree can be done easily without it. Our task is to add on some segments and then find the modified array. There is a nice trick to do it. We will count difference array d[]. To increase by x on segment [l; r], we need to add x to d[l] and substract x from d[r + 1]. Then, after we applied all the operations, to get the modified array we simply need to calc prefix sums on this array.

    My solution:159060471

    • »
      »
      »
      23 месяца назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      The same idea came to my mind during the contest, unfortunately, time wasn't on my side.

      Thank you so much for the explanation.

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

      i m not getting how to use segment tree here could u please explain how are u planning to implement

      • »
        »
        »
        »
        4 месяца назад, # ^ |
          Проголосовать: нравится +1 Проголосовать: не нравится

        You basically need to mark that you need to add an edge between ith and (i-1)th vertex for each i between l and r. That means you want to set value 1 on some segment, you can do this using mass segment tree.

»
23 месяца назад, # |
  Проголосовать: нравится +24 Проголосовать: не нравится

With video editorials and hints for each problem. You cannot argue that these are not one of the best editorials to be seen in a while on CF.

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +23 Проголосовать: не нравится

D admits an O(n) solution. It is sufficient to check that the sums of the subarrays between any positive integer and the next/previous greater (or equal) integer, are negative and greater in absolute value than the positive integer itself. If this holds for all positive integers, then we return yes.

Intuitively this makes sure that no positive integer can contribute positively to some other positive integer which is greater than it.

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

    word

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

    Hi, i think i have done something similar. don't know whats wrong https://codeforces.com/contest/1691/submission/159059179

  • »
    »
    23 месяца назад, # ^ |
    Rev. 2   Проголосовать: нравится +13 Проголосовать: не нравится

    I try to prove your solution. (edit: earlier proof was wrong)

    Suppose a subarray which violate the condition be $$$a[i:k]$$$ and let the index of maximum element in this subarray $$$i$$$. Also let us say wlog, that the subarray extends towards the right, ie, $$$[a_i, a_{i+1}, ... a_{k}]$$$. Let us say that the element just smaller than $$$a_i$$$ be at index $$$j$$$ in this subarray.

    $$$[a_i, \color{red}{ a_{i+1}, a_{i+2} ... }, \color{turquoise}{ a_j,} \color{blue} {a_{j+1}, a_{j+2}...a_{k}}]$$$

    If the sum of blue subarray, ie, $$$a[j+1:k]$$$ is positive, then, we find new subarray which violates the condition to be $$$a[j:k]$$$ of the same structure as $$$a[i:k]$$$ and repeat the process on this subarray

    Otherwise if sum of $$$a[j+1: k]$$$ is not positive, then we safely discard this subarray, and here we end up with $$$a[i:j]$$$ as violating subarray, which we check in your solution. (because if $$$a[i+1:k]$$$ is positive and $$$a[j+1:k]$$$ is non positive then $$$a[i+1:j]$$$ is positive)

    it it correct or there is some flaw

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

      The way I verified it myself before writing it was very similar; I also tried to demonstrate that you can safely chop off the sides and condense the violating subarray to one which is sandwiched between these two particular elements.

      I think it is sound.

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

      That's wrong proof bro. You are saying if sum of blue array will be positive then you'll have a smaller subarray violating this condition. You're totally wrong here.

      Case: 2, -1, 1, -1, 2

      [0,4] is the smallest one. [2,4] has sum > 0 but it is not the smallest.

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

        blue subarray was just to the right of second smallest element, in this case it would be empty.

        Earlier proof was wrong but this was not the issue, please check now

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

    How do you find the "nearest" greater element than $$$a_i$$$ for each $$$i$$$ in linear time?

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

    10 -4 3 -4 10 should be "NO" and your solution will give "YES" if I understand correctly

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

      Edited my comment to say we search for nearest greater than or equal integer, not strictly greater. Doing that, between 10 and 10 we have-4+3-4 is not less than -10, hence allowing the 10 to connect with the other 10 positively, violating the condition and giving us a NO.

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

can the person who added the binary search tag for D, share his approach?

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

    I think, in segment tree you use some kind of binary search, and intended solution for D uses segment trees :)

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +13 Проголосовать: не нравится

    You can find closest greater on right/left using the binary search and some data structure like segment tree or sparse table.

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

It was nice round! I really liked problem D, I hope to see more similar problems in future rounds :)

»
23 месяца назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

The best way of editorial. Loved it!

»
23 месяца назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

If you are/were getting a WA/RE verdict on problems from this contest, you can get the smallest possible counter example for your submission on cfstress.com. To do that, click on the relevant problem's link below, add your submission ID, and edit the table (or edit compressed parameters) to increase/decrease the constraints.

If you are not able to find a counter example even after changing the parameters, reply to this thread (only till the next 7 days), with links to your submission and ticket(s).

»
23 месяца назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

here's my python DP O(n) solution for D O(n) DP solution for D

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

HI boys Can anyone explain why am I getting a Runtime Error here 159082911

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

    For n == 1 you're not taking the input array (a single element) which is becoming n for next inputs which is causing RTE.

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

In problem c I didn't get how all middle ones contribute to 11?? Can anyone help with this

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

    Ohh i think si-1.si -->Di-1 si.si+1 -->Di

    [Si-1*10 + (Si ]+ [ 10*Si) + Si+1] --> Si-1*10 + Si+1 + Si(11) Total contribution is 11 Got it

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

great contest and solutions too!!

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

x

»
23 месяца назад, # |
  Проголосовать: нравится -6 Проголосовать: не нравится

D was doable with a classic algorithm called cses. So you maintain a segtree which returns the maximum subarray sum of the entire array. You insert the values in in increasing order of arr[i]. At every stage, if the maximum subarray sum is > the value inserted, the answer is NO, otherwise it is YES. Let's say the current value inserted is x. Since the values are inserted in increasing order, the maximum value in the entire array cannot exceed x, so the maximum subarray sum will be greater than any possible "max value of a subarray" if it is greater than x.

»
23 месяца назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Can anyone tell the time complexity of this code? That code seems to be O(n^2), but this code got accepted in problem D . Please check. Submission link: https://codeforces.com/contest/1691/submission/159084501

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    The tests in problem D are weak. Actually for the worst case it works in O(n^2) and it is hacked now.

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

What is the 1213th case in the 7th test of D? I am getting WA. Here is my submission.

I will be really obliged if someone finds the error. Thanks in advance.

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

I am getting a run time error on my submission can anyone chech why that is https://codeforces.com/contest/1691/submission/159039369 thanks in advance!!

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Here's a testcase on which your code gets WA: Ticket 9111. Not sure if it contains the reason for RE as well, but it should be a good starting point.

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

Really liked the editorial with hints, and video solutions make this editorial to next level. Thanks for such a great editorial

»
23 месяца назад, # |
  Проголосовать: нравится +113 Проголосовать: не нравится

There is another solution of F. It is simiral to editorial, but a bit shorter. We can fix a root of the sub-tree $$$v$$$, then for each edge $$$e$$$ between $$$v$$$ and $$$u$$$ let's calculate

$$$\sum\limits_{R \in subtree_u} \sum\limits_{S \subseteq V, |S| = k}f(R, S) = (cnt(v) - {size_u \choose k}) * (n - size_u) * size_u$$$

where $$$subtree_u$$$ — vertexes if the sub-tree of $$$u$$$ if $$$v$$$ is the root of the tree, and $$$w$$$ is connected to $$$v$$$. $$$size_u$$$ is a number of roots of the tree, $$$n - size_u$$$ is size of the sub-tree, $$$cnt(v) - {size_u \choose k}$$$ is a number of subsets of size $$$k$$$ such that sub-tree of $$$v$$$ is the minimum-size sub-tree covering it entirely and $$$R \in subtree_u$$$

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

The remaining 1s can stay where they are as they will anyways be contributing a value of 10 no matter which position they take.

There should be 11 instead of 10 in the above sentence.

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

Isn't Hint 2 of problem D Editorial of no use at all?

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

Thanks for the fast editorial as well as making this round, enjoyed it a lot!!!

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

where are video editorials?

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

I do not get it, is there some more hidden edgecase in C?

Why my 159111480 fails?

»
23 месяца назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

Problem D can be solved in $$$O(n)$$$ operations, in a quite straight-forward manner with a monotonic stack, without any special consideration for positive/negative values, etc: 159111942.

»
23 месяца назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

A solution for problem E using only vectors:

First, consider the segments that are completely inside another segment of the same color. Let's call these "islands".

If an island intersects with any segment of the other color, we can completely ignore it — because any connection chain involving the island can use the bigger segment instead. If the island does NOT intersect with any segment of the other color, then it is its own connected component — so it contributes 1 to the answer but can otherwise be ignored.

Processing the islands can be done with sorting and the two-pointer technique (or binary search).

Now, for the rest of the segments. Sort the segments of each color separately (note: since we got rid of the islands, sorting by left endpoint is the same as sorting by right). Now, go left to right, keeping track of the rightmost point reached with each color. If it's possible to intersect the next interval of either color with this point, do so. Otherwise add 1 to the result.

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

    Clever idea! For ones for whom it is a bit subtle how to check island intersections with two pointers, you can sort out all islands in one array and non-islands in the other. Then take islands and non-islands of different colors, sort islands increasing right-end and non-islands increasing left ends. Then processing current island $$$I_c$$$ you may take the most-right non-island $$$NI_c$$$ starting before (or at) the current island right border. Checking that right border of $$$NI_c$$$ is inside $$$I_c$$$ answers whether there is any intersection. The subtleness here is that should we have sorted islands increasing left-ends the check would not have worked. Example islands [1...5], [2...3] and non-island [4...6]. We see [1...5] intersects with [4...6], but then standing in [2...3] we've already moved our non-island pointer too far and now it starts after [2...3] end.

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

Wrong answer in 4957th token, what's the testcase? 159113795

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

Someone, please tell me why I am getting TLE on B My Solution on test case 30. I think it is just O(n).

»
23 месяца назад, # |
  Проголосовать: нравится +26 Проголосовать: не нравится

For E we can also run dfs and extract edges using segtree/merge sort tree.

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

For problem B, can anyone tell me why I am getting TLE on this 159020121 when I submit using GNU G++ 17 7.3.0 but the same solution gets accepted when I submit using GNU G++ 14 6.4.0 (159121654)

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

In problem 1691E — Number of Groups, I implement using the way as editorial did

  • First using a set for ordering the points (159130522) gets WA
  • Then I tried to change it by using a vector (159131112) gets AC

Why is the set solution getting WA while the vector solution getting AC where I used the same custom comparator in both submissions?

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

it isn't enjoyable ..XD the wrong answer expected NO, found YES [4957th token]

can someone tell me/(give any tc) where it's failing? 159139893

»
23 месяца назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

Here is my O(n log n) solution, but it's much shorter and simplier to understand than in editorial. The main idea is that we iterate through elements in increasing order, then we should look for the segment that has the maximum possible sum and contains our element as maximum. How do we do that? Let's mark elements in the array if we have already looked at them. Also let's store segments of continious marked elements. In these segments we will store sum, starting and ending point of segment, maximum prefix sum and maximum suffix sum (it can be zero). For simplicity we will store segments in array. If we have array [l, r] we will store it only in a[l] and a[r]. Imagine we have element x in position i, then we should look for the segments which are stored at a[i - 1] and a[i + 1] (if it is possible and they are marked). Then we count maximum sum, it is (i ? a[i - 1].suf : 0) + x + (i + 1 < n ? a[i + 1].pref : 0), if it's greater than x, then answer is NO. Then we update sum, pref, suf and store new segment in a[a[i - 1].start] and a[a[i + 1].end]]. Here is code 159141199.

PS: sorry for bad english)

»
23 месяца назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

Why in F you asked for answer for only one k, and not sum over all? Solution doesn't change I think but implementation becomes easier a bit

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

Thanks

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

In the problem B the solution is not correct ! The corner test case :

INPUT.TXT 1 4 2 1 2 1

OUPUT.TXT 3 4 1 2

But the result of the tutorial solution is -1

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

Can we do problem E with dfs? I have tried but I'm not understanding what is wrong.
I have separately sorted red and blue according to 1) start points, 2) end points.
And then found the range of other color which will lie within the same color range. and visited the segments using DFS. I have considered the dfs as bipartite graph.

code

Anyone, pls help

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

How weak are tests in D? My check was that no two adjacent elements are positive, and then run a kadane's starting from indices [0, 20). That passed XD

I was thinking it's some randomized argument but I can't prove it. Someone please hack me and put me out of my misery

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

Alternate solution for E using segment tree and coordinate compression:

https://codeforces.com/contest/1691/submission/198382960

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

Why am I getting WA on C? My idea is same as the one mentioned it the tutorial. Submission: 198856079.

Spoiler

variety-jones?

  • »
    »
    13 месяцев назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Well, why are you pinging me? You can as well purchase a subscription if you need instant help. Or better, improve your debugging skills.

    Take a look at Ticket 16774 from CF Stress for a counter example.