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

Автор Vladik, 6 лет назад, По-русски

epam

Привет, Codeforces!

Рад анонсировать и пригласить вас на Codeforces Round 689 (Div. 2, based on Zed Code Competition), который пройдет 11.12.2020 17:35 (Московское время).

Мы хотим предложить вам для решения 6 задач взятых с Zed Code Competition 2020, который проводился в рамках конференции Adapt by Zed компанией EPAM Systems.

Этот раунд будет рейтинговым для участников, чей рейтинг ниже 2100.

Всем выше перечисленным огромное спасибо за вклад, внесенный в подготовку раунда, а вам удачи на предстоящем соревновании! :)

UPD: Разбалловка для задач: 500 — 1000 — 1250 — 1500 — 2250 — 2750.

Поздравляю победителей официального зачета:

  1. yash_daga
  2. AiriKatagiri
  3. tejas10p
  4. RNG-Ming
  5. meidong

а также победителей неофициального:

  1. neal
  2. Geothermal
  3. LayCurse
  4. emthrm
  5. hank55663

Спасибо всем за то что приняли участие. Желаю приятного дорешивания! (разбор)

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

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

As a tester, 1 in 7 children does not have enough food to lead a happy and active life, but what does it take to end global hunger? Participate in Codeforces Round #689.

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

As a tester, I love Zebras!

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

I think it will be a good contest!

Good luck to everyone!

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

As a tester, wishing you all Happy Rating :)

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

BRCode Will there be 3b1b styled tutorials xD?! Im aware it must be really hard to make but they're really great BTW don't stop making them.

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

[copyright striked by Digon]

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

I will be glad to participate and test my knowledge

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

The unseen bug is the deadliest

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

Good luck everyone ❤️

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

As a tester, I want to wish you good luck and high rating!

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

I suspect there's a problem that will require Z-algorithm. ;)

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

As a tester the problems were very interesting :)

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

    Were the problem statements short, sir?

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

      Why everybody wants to see short statements? It is not so difficult to read legends, if they are not very long, of course.

      As an author of 672 round I would like to say that some authors love interesting legends in their statements. It is such a pleasure to make tasks about your favourite films, or games, or even about your friends.

      Of course, I can understand participants. Rounds require speed. But to my mind, one or two minutes spent on the legends are not impotant.

      Please don't downvote me for the unpopular opinion.

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

        Sorry. I want to see short statements because I want to see the beauty in the problems instantly. And by beauty I mean algorithmic and mathematical beauty. I don't care about the story, and even while upsolving, I become very happy to see a problem which has a short formal description but very hard to think. Most recently: 986C - AND Graph, I bookmarked this problem even after solving it, I was so happy.

        Also, my dad peeks into my laptop from time to time, and if he sees me solving a problem related to zebras and cookies and Gildong the dog, he will question my career choices. That is why I always switch to some AtCoder problem (without flavour text) when he is around. :P

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

        But some people like me are bad at English and have to use the Google Translate to read the problems,and long statements are difficult for them to understand >_<

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

          There was a really great round 635, where statements have legends, followed by a picture. All that lies above picture is a legend, all that lies below — a statement.

          This trick solves your problems with English.

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

            Thanks for that.
            But actually,**few** CF problems with long statements has a short formal description below the legends.
            I strongly suggested that if the author want to make the statement long,at least he need to add a short formal description.
            Besides,the long statement may has some confusing words that may lead some competitors with bad ability of understanding(like me) understand the problem in a wrong way,and wastes a lot of time.

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

              No, I disagree. If I will have a legend and a task apart, it will look like "listen, I have a legend, but nobody cares about it so here is a formal description".

              Real life tasks most commonly don't have formal statements.

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

          What's worse,when we copy the statements to the Google Translate,the Markdown and the $$$\LaTeX$$$ would be lost.

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

        I think one issue is some legends don't really add anything to the problem. Legends like having a city connected by roads being described by a graph or two playing a game and determining the winner if both players play optimally seem natural. Legends like someone receiving and array for their birthday and having to calculate some property of it seem a little contrived. Then there are those legends where person A proposes a problem to person B and person B can't solve it for reasons like not having enough time, being too young or being too small and now they ask you to solve it for them. There's also the other situation where person B can solve it and they want to know if you can solve it too. Some of these can be entertaining but also feel a little unnecessary.

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

          I'm strongly agree with you! Legends like "birthday" or "B can't solve" or "can you solve it too" are so annoying! Honestly, I... well... At least I don't like this types of legends (i don't like it very, very much).

          However, I was talking about good legends, without this typical words about birthdays or "A wants to solve but can't".

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

          How did you know that mike recieved an array for his birthday lol.

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

What is the problem score distribution?

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

I hope Vladik will put me on the tester's list. ⊙︿⊙

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

Wow netman, was once an IGM. I thought Vladik was the highest rated at first. Looking forward to some really good math problems.

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

I'm trying but not getting better. I hope I will do well in today's contest.

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

score distribution ?

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

What is the score distribution of problems ?

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

bad contest.

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

And now I want to ask you: were the problems' statements short enough? :)

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

Anyone else found B to be a mere implementation exercise? It took me almost 2 hours, mostly because I kept telling myself that Codeforces either wants a "smart solution" or a super dumb solution. C looked cool, though.

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

I hate Probability

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

Great contest! I thought I had registered but apparently, I did not, that cost me 10 minutes of the contest and my mistake ended in an emotional downturn the rest of the time :(

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

I hate Probability.

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

How to solve C ?

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

    Find such maximal position X that for all i > X it is true that a[i] = i.

    Then just calculate the answer with a well-known formula:

    ans = 1

    if (r[i] >= X) ans = ans * (1 — p[i])

    Answer is 1 — ans.

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

    Here is how I thought about it : First we find the first index such that the suffix of the array is sorted. Now inorder to make the array not sorted after m operations, the elements at index = (first_index-1 to n) should not be sorted. Then just do 1-x as we have to find winning probability. Idk why it fails on pretest 2.

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

    Well first find the length of the largest suffix of a that is sorted in ascending. Say it has length len. Then let x = n-len. Clearly, if any operation (r, p) has r >= x, the whole array is sorted. Lets say we have opi1, opi2, ... opik where 1 <= i1 < i2 < ... < ik <= m, such that the previous condition is satisfied. picking any combination of these operations to go through to sort the corresponding prefix of array a will suffice to sort the whole of array a. Also an interesting thing is the probability of this occuring is exactly 1 minus the probability of the complement, that is, none of these operations going through. None of the other operations opi matter if it doesn't belong to the previously said list. Now the probability of this compliment, is just the product of (1-pi1)(1-pi2)...(1-pik). As I already said, ans is 1 minust that. One corner case is if array is sorted to begin with, in which case the answer is just 1.0. (As ops don't affect array)

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

      I did the same thing, I was a bit confused about the corner case first. So here's a thought : If some prefix of the array is already sorted given that (prefix_index>first_index where suffix is sorted) then we should not count it in finding the winning probability as no matter we include it or not the array will always remain sorted! This logic handles the corner case well and also makes more sense. However we count it's contribution to the final answer, why is that?

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

        Because in the given corner, if we use the same algo logic, we'll be ignoring the case where, even if all those ops with r >= x don't go through, the array remains sorted. Which means, the product that we subtract from 1 normally, isn't valid in this case. That's literally the only difference between the ans of the algo and the way we handle the algo.

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

Could not understand question C. Can anyone help?

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

Nice problemset

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

What may be

  • test 2 of problem C
  • test 13 of problem E

?

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

Can anyone pls explain the solution of problem B...? :(

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

How to solve E?

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

    My solution breaks it into two cases, although maybe someone else can provide a more concise solution.

    I won't detail the exact formulas, but you can see them in my submission.

    Case 1: $$$x \geq y$$$

    The overall value of $$$k$$$ diminishes over time, so we should greedily add $$$y$$$ whenever possible to prolong the time the cooler amount stays above $$$l$$$. Initially, for some number of days, we won't be able to add $$$y$$$ without overflowing past $$$r$$$, so our cooler amount decreases by $$$x$$$ for each of those days. After a certain point, we will always be able to add $$$y$$$ without overflowing, so our cooler amount decreases by $$$x - y$$$ for the remaining days. We can calculate all this information in $$$\mathcal O(1)$$$ with some math.

    Case 2: $$$x \lt y$$$

    Because $$$y$$$ is greater, we can always first let the cooler drain at a rate of $$$x$$$ for as many days as possible, before adding $$$y$$$, then repeating. This is optimal since we're only refilling when absolutely necessary, so we don't risk overflowing $$$r$$$. There might be an $$$\mathcal O(1)$$$ math formula for this, but I'm not sure. I did $$$\mathcal O(x)$$$: whenever we add $$$y$$$, it's because we can no longer drain any more $$$x$$$, so $$$0 \leq k - l \lt x$$$. We can thus treat this as a graph that cycles through nodes $$$0 \dots x - 1$$$, and if we ever encounter a cycle, we know that going through this cycle will sustain the cooler capacity for the entire $$$t$$$ days.

    I know that wasn't the clearest explanation (I found it a bit difficult to put into words), but hopefully the code can clear up any doubts. https://codeforces.me/contest/1461/submission/100945988

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

These error involing precision always frighten me. Solved D,E but could not C even after many attempts. Can anyone help what is wrong with my code? https://codeforces.me/contest/1461/submission/100926909

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

how to solve E??? Can't even know how to approach...

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

I was implementing an inclusion-exclusion for c but kept getting tle on pretest 10.

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

Is it just me or was C too easy? B felt harder to implement.

My approach for C, If you know array after idx is sorted, then any operation that operates on idx or above will completely sort the array. So probability of atleast one such operation = 1 — probability no such operations happen.

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

I think D is well-known. upd: Divide and Conquer DP

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

What was the logic for problem B

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

Could someone tell why my problem C code was giving TLE .

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

Am I the only one who wasted 30 minutes on C and then realizing that I took forced the solution to the next test-case without reading the queries for that problem
PS: spookywooky can relate :(

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

How to optimize B ?

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

Some one please debug my code for Q4 100952421

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

Is there any other way than dp for B?

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

Very nice problemset!!! XD

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

How to solve D ?

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

    I believe segment tree should do it, just sort the array beforehand. For some reason I could not get the second test in the given pretest right, so I didn't submit. But still it seems relatively simple. Correct me if I'm wrong.

    The method I thought of is instead of getting the traditional tm = (tl + tr) / 2, we use binary search to find the first index greater than our mid element.

    And finally, you insert the sum from tree[v] into some set. In the end for each query if you can find it in the set it's possible, otherwise not.

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

    Just a simple "merge sort"-like recursion will do it all.

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

      I thought that only , but if we divide the array into two parts , and sum of both left and right is greater than sum required then we have to check in both half . So wouldn't that take O(n) per query ?

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

        You need to precompute all the possible sums using divide and conquer. Then ,for each query, you just need to check if the required value exists or not (using a Map,for example).

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

        Just calculate sum of both left and right array and store it in set. After this call for next two halves... You can traverse the array for sum calculation or use prefix sum also..

        Then for each query check the no. in set and print accordingly...

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

        We devide the array in all possible subarrays, and store the sum for each one somewhere.

        Then while queries we can "directly" give the answer in log n.

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

        No, actually it is much faster than it looks like.

        It is easy to see that the maximum depth of recursion is $$$log(n)$$$ because each time we are splitting the array into two halves.

        In each level we are doing at most $$$n$$$ operations, by summing up each part of the array.

        So that's a total time complexity of $$$O(n*log(n))$$$.

        Bonus: we can actually do the summing part much faster by calculating the sum of the desired interval from the sums of its two halves, so that's $$$O(n)$$$ time for the whole recursion instead of $$$O(n*log(n))$$$, but the total time complexity will remain $$$O(n*log(n))$$$ because of the sorting we are doing at the beginning.

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

        you can precompute all the possible answers in nlog(n) , then you can answer each query in O(1) time . giving a total complexity of O(nlog(n) + q)

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

    Do exactly what the question says. I literally had a vector in a queue and pushed left vector and right vector into the queue and continued doing so until vector size is 1.

    Basically I calculated all sums possible from a given vector, the complexity would only be O(nlogn)

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

Does N*M*M/2 pass in B?

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

B is harder than C and D, imho

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

I solved A in 2 min and then struggled with B for the rest of the competition, can somebody tell me CLEARLY how to solve B ? (I know it is just implementation, but how ?)

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

The values of r may not be necessarily distinct in problem C (:

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

How to implement solution of B?

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

    you can refer mine 100926055.

    dp[i][j] in my solution denotes largest length of spruce that can be made from the coordinate (i,j).

    Hope it helps!

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

    we will use DP! lets call maximum possible k for a tree rooted at (i, j), mem[i][j].

    lets call c[i][j] the minimum number of consecutive *'s from left of the cell or from right of it (including the cell). this can be found using partial (prefix) sum and binary search in O(log(N)).

    Then the maximum possible k for the cell bellow (i, j) ((i+1, j)), is min(c[i+1][j], mem[i][j]+1), because:

    1. mem[i][j] needs to be at least k-1 for mem[i][j] to be k.
    2. a k tree has 2k + 1 *'s at the base.

    Then the answer is just sum of all the mem[i][j]s.

    Submission using this principle.

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

The system test for E is weak. I hack someone with the following test after the system test: 31 2 48 27 3 2

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

Interesting problemset!

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

weak pretests :/

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

what sould be the time complexity for problem B? will N^3 solution will pass??

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

I am getting WA on test case 20 in problem C (I think it is about precision). Can someone help?

My submission

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

I liked the pictures in the questions, but for QB, adding a pragma after comp ends up ACing.WHY!!!!??? :(

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

Can someone please point out what is wrong in my solution for problem C. It got fst on testc-case 25

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

I may have found F interesting, only if s was always "+*".

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

Why does C fail if we use float instead of double? 100933790

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

what is the limit of memory that can be allocated on runtime in C++?

my solution for B failed system test because i was allocating (3*500*500) at worst.

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

what is limit for memory allocation in C++ during runtime?

my solution for B failed system test because i was allocating (3*500*500) memory at runtime in worst case scenario.

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

I haven't solved E but I know a TestCase where 1 solution fails I know I can't hack it but is there a way to hack now for somebody else or it isn't possible after system testing.

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

100962567 In spite of using 3 loops(O(N*N*M)) in B, my code gave Time Limit Exceeded on main test case 4.

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

I think the B is bad. I spent 15 minutes thinking about how to improve my $$$O(500^{3})$$$ brute-force because 1e8 is dangerous. However, in fact $$$O(500^{3})$$$ can pass it easily. So, what's the meaning of the B? Just for testing Brute-force?
If so,that is obviously unresonable.

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

Problems B and D were about justifying to yourself why brute force should work :P

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

x

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

List of ideas that solve F: 100956230

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

Thank you very much, I managed to get back to green after almost a year!

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

For problem D, I used the following solution: 1. sort a. 2. compute prefix sum of a for efficient range sum operations 3. for a given sum s, call the helper method check on the entire range of a.

In this helper method check, do exactly what a split operation allows us to do: 1. split by middle value midV; 2. do a binary search to find the right most index midIdx such that a[midIdx] <= midV. 3. then check the range sum of [l, midIdx], [midxIdx + 1, r]. If one of them equals sum, return true; if both of them are smaller than sum, return false; if they are bigger than sum, recursively check on that range.

The terminating condition of this check method is: 1. l > r, left index is bigger than right index; 2. the range sum of the current range is < sum; 3. the range sum of the current range is > sum, a[l] == a[r], meaning we can not split anymore. 4. if the range sum is sum, simply return true.

My submission is 100978064

I keep getting the stack overflow error on one of the recursive call but I can't figure out why my terminating condition is incorrect. Can some one help me with this? Thanks!

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

I made a stupid mistake. In the c problem, when the array was originally ordered, I directly continued, ignoring the following input. I submitted this question for the first time at 00:51 and passed it in the last ten seconds. It is because of this stupid mistake. So I have an idea, can someone sum up some common stupid mistakes and share them so that when the solution fails to pass, we can first check whether they have made these stupid mistakes (if no one does this, maybe I will Do it).

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

Finally master! Thanks for very interesting problems and i got a little distance from winners!

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

I recieved a system message about my submission for Problem D coincides with other's submission. But I always use the same FastIO module which can be proved by my previous submission. I don't understand why it's considered a violation of the rules this time