O--O's blog

By O--O, history, 21 month(s) ago, In English

Hello, Codeforces!!

We are happy to invite you to TheForces Round #7 (ClassicForces), which will take place on [contest_time:430673]

You will have 2 hours to solve 6 problems

Discord Group

Contests' archive

  • Vote: I like it
  • +65
  • Vote: I do not like it

| Write comment?
»
21 month(s) ago, # |
  Vote: I like it +17 Vote: I do not like it

You guys are doing a fantastic job. Thank you for organizing such contests.

»
21 month(s) ago, # |
  Vote: I like it +9 Vote: I do not like it

great

»
21 month(s) ago, # |
Rev. 2   Vote: I like it +44 Vote: I do not like it

Few things to add as the problemsetter.

Recently some of my peers opened/reopened a Coding Club in my college. I had prepared this contest to inaugurate that event, to make more people in and around my college be more interested in CP, so that they try out the thrill and beauty of this sport. This is the first time I tried preparing problems, so you might find problems very classical, or similar to some other problem you have solved in the past. Also the target audience was mostly people new to coding, so problems will be around Div 3-4.

I would like to thank the testers (and good problemsetters themselves):
blitztage for being the first person to be willing to test the problems
Newtech66 for helping and supporting me with problem preparation
Psychotic_D for discussing these and several other problems with me
O--O for deciding to publicise this contest

Lastly, I hope you participate and enjoy the round. Also, I would love to hear some feedback from you guys so that I can improve myself.
Upd: I hope you liked the problems. Any feedback or scope for improvement? (apart from the time limit for E which wasn't very helpful for participants using py)

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    looking forward to participate :)

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    With pleasure! Thanks for using magic to show my name as yellow, long time since being yellow!

»
21 month(s) ago, # |
  Vote: I like it +5 Vote: I do not like it

Is contest rated?????

»
21 month(s) ago, # |
  Vote: I like it +11 Vote: I do not like it

I'm so glad that we could create such rounds with the help of each other, And huge thanks to merlin_ for preparing these problems, I hope our official codeforces round gets reviewed by some coordinator soon, And then we'll have a great surprise for you.

»
21 month(s) ago, # |
  Vote: I like it +23 Vote: I do not like it

Why you do not organize an official round? You create so many problems and more people could solve them.

»
21 month(s) ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

Can you check the discord link, its showing invalid at my end

UPD: the link is working now

»
21 month(s) ago, # |
  Vote: I like it +5 Vote: I do not like it

excited less gooo

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

5 mins delay > _ <!

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve F?

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    by binary searching on the segment tree.

  • »
    »
    21 month(s) ago, # ^ |
    Rev. 2   Vote: I like it +8 Vote: I do not like it

    No need of a segtree. You want to find for every i, the max j less than i such that dp[j] + prefix_sum[j] <= prefix_sum[i]. You can maintain this in a vector by push and pop.

    https://pastebin.pl/view/2817a620

    • »
      »
      »
      21 month(s) ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      How are you maintaining increasing subarray things? Can you explain a bit!

      • »
        »
        »
        »
        21 month(s) ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        I am popping the last element till it is bigger than the cirrent value. You can see that in the paste

  • »
    »
    21 month(s) ago, # ^ |
    Rev. 2   Vote: I like it +11 Vote: I do not like it

    I did it using a segment tree (which could be avoided),

    You have calculated minimum $$${S_m}$$$ till the $$${(i - 1)^{th}}$$$ index and now you are on $$${i^{th}}$$$ index, assume that the answer for this index is the subarray from $$${[a_j,..a_i]}$$$ so for this to satisfy the non-decreasing condition, the following should hold

    • $$${P_i - P_{j - 1} >= dp[j - 1]}$$$,

    here $$${dp[j - 1]}$$$ is the answer till the prefix of length $$${(j - 1)}$$$ satisfying the condition mentioned in the question, we now just need to see whether the condition holds for the last subarray as well.

    • $$${P_i >= dp[j - 1] + P_{j - 1}}$$$

    Now, you need the last index less than $$${i}$$$ where this condition holds, we can store the right side term for each index in the segment tree and Binary search ($$${as\ function\ is\ monotonic}$$$) for the last index, this can be done in $$${O(Nlog(N))}$$$ or $$${O(Nlog^2(N))}$$$.

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I did dp + bs + segtree

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem E is a dp problem. I always get stuck in dp problems and am close to the solution but not enough to get AC...

My solution for the example test case:

15
256
653180378

It fails in large inputs (the last one).

Can anyone spot the bug?

Code
  • »
    »
    21 month(s) ago, # ^ |
    Rev. 3   Vote: I like it +5 Vote: I do not like it

    Ok, my first approach got MLE (dp[i][val][prev], space complexity $$$O(n^3)$$$) but a nice observation is that we only need the previous 2 values only (dp[2][val][prev], space complexity $$$O(n^2)$$$).

»
21 month(s) ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

How to solve Problem D

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Solve each quadrant separately. Sort all points about their slope. Your answer is number of distinct slopes. For slope comparator use integer multiplication only. Annoying edge case when (0,0) is present in array.

    https://pastebin.pl/view/d6a3be9c

    • »
      »
      »
      21 month(s) ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks Can you give the solution of Problem C

      • »
        »
        »
        »
        21 month(s) ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Your edit may confuse people since earlier you asked for a solution of D. Better make a separate comment for C.

    • »
      »
      »
      21 month(s) ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      You could actually just divide the x and y coordinates by the gcd of their absolute values and count the number of distinct pairs. This separates them into the right quadrants automatically.[submission:196421985]

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve Problem C

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Min is the max value — min value. Max is just the sum of any group of n-1 points of the maximum difference it can have with another point. This works because the first and last points will be always connected with this setup and the other nodes will cover the largest distance they can possibly cover.

»
21 month(s) ago, # |
  Vote: I like it +11 Vote: I do not like it

Hi, some things i liked about todays round :

  • B and C are good problems

  • E is good dp practise and F has a good idea too.

Some criticims :

  • i assume n^3 is intended in E, however my solution barely passed in TL only after optimizing constant factor, could you raise the TL/lower n in the future

  • another TL related issue on D, if you tried to calculate inverse tan of angles

  • D had quite a few cases for myself tbh, but perhaps my solution could be improved, i would have loved to see x, y>0, it doesnt reduce the level of idea needed to solve, just makes it more pleasant.

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it +16 Vote: I do not like it

    You can avoid floating point operation altogether in D. TL could be intended for that.

    • »
      »
      »
      21 month(s) ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      yes i know, i did infact solve it without floating point in the end

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Thank you for your feedback, and also for participating. I honestly did not expect so many of you would be willing to solve my problems.

    E was O(n^3), and I didn't realize TL would be that tight. My java soln takes the same time as ur c++ one. Still, I will try to set a more lenient TL in future.

    D's intended soln was involving mapping slopes of lines. I had figured 2-3 solutions using floating point numbers, and failed all of them.
    Brief history, this is actually the first problem I ever came up with (no 2nd, umnik rejected a binary search problem I proposed on codechef 2/3yrs back). I had first thought of x,y>0 only, then I extended the problem to add some casework. I guess I just wanted people to think/spend time on my first problem, even though they got the idea right away.

    I hope I can come up with a better problemset in future, which you would enjoy solving more.

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

E was nice

»
21 month(s) ago, # |
  Vote: I like it +13 Vote: I do not like it

don't ever use Python in TheForces

Problem E will beat u to axx