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
Problems were prepared by merlin_
Would like to thank our testers: Psychotic_D , blitztage , Newtech66 , O--O
- Also we want to thank you for participating in our round
Winners
You guys are doing a fantastic job. Thank you for organizing such contests.
great
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)
looking forward to participate :)
With pleasure! Thanks for using magic to show my name as yellow, long time since being yellow!
Is contest rated?????
no
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.
Why you do not organize an official round? You create so many problems and more people could solve them.
Can you check the discord link, its showing invalid at my end
UPD: the link is working now
excited less gooo
5 mins delay > _ <!
How to solve F?
by binary searching on the segment tree.
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
How are you maintaining increasing subarray things? Can you explain a bit!
I am popping the last element till it is bigger than the cirrent value. You can see that in the paste
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
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.
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))}$$$.
Cool Thanks :)
I did dp + bs + segtree
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:
It fails in large inputs (the last one).
Can anyone spot the bug?
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)$$$).How to solve Problem D
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
Thanks Can you give the solution of Problem C
Your edit may confuse people since earlier you asked for a solution of D. Better make a separate comment for C.
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]
How to solve Problem C
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.
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.
You can avoid floating point operation altogether in D. TL could be intended for that.
yes i know, i did infact solve it without floating point in the end
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.
overall it was a pretty good problemset :)
E was nice
don't ever use Python in TheForces
Problem E will beat u to axx
just kidding, fun contest though