Hello Codeforces !!
Aparoksha is back with the second edition of the flagship-event CodeRed.
Last year's CodeRed 2018 was a great success with over 900 teams registering for it.
If you have the appetite for algorithmic problem solving, then don't miss it out!
It will be a 4.5 hour long team event with a maximum size of the team being 3 members.
The participants need not be from the same college/institution/organization.
The preliminary round will be held on Codechef, and the onsite round will be held during Aparoksha.
The total prize money is worth INR 125,000 (Including goodies for all teams selected for onsite round, travel expenses* and cash prizes worth INR 50,000).
The best 40 teams will make it to the onsite round.
Also, top 3 teams in the online round will get INR 4500, 2500 and 1500 respectively, along with Codechef Laddus.
All teams making it to the onsite round will get CodeRed T-shirts.
Contest link is here — CodeRed 2019.
The problem set comprises 7 problems of varying difficulty level.
So be ready to have a nail-biting experience on March 2, 2019 at 21:00 IST.
The problems have been set and tested by Shivam Garg (shivamg_isc), Ankit Rao (hybrid), Sahil Prakash (prakashs99), Vaibhav Srivastava (dbest077), Saurabh Kumar (shauryakr) and Mohammad Aquib (aquib786).
Special Thanks to Teja (tejavojjala) and Sacheendra (sacheendra9044) for their valuable input.
Facebook Page — CodeRed Facebook Page
See you in the ENDGAME :D !!
Upd 1:- Contest is about to begin in almost 1 hour. Best of luck :)
Upd 2:- The contest is over, and was a great success with a mammoth 1271 teams registering for the contest.
Thanks for the overwhelming response. :D
Congratulations to the top 5 winners :D
- farhodkerimtemurbek — Kerim.K, Farhod_Farmon
- 1e9+7 Bugs Per Second — Ashishgup, Slow_But_Determined, vntshh
- PaduKeDeewane — hitman623, Enigma27, _shanky
- Ryuzaki — Hiren.Vaghela, Learner99
- fast_coders — acraider, nitixkrai, fsociety00
Top 3 teams will get cash prizes of INR 4500, 2500 and 1500 respectively, along with Codechef Laddus. :)
Feedback of the contest in the comments will be highly appreciated :D
The detailed editorials will be posted on Monday.
For now, I am posting the hints.
It was a digit DP problem. The states of the dp could be dp[index][previous][size - of - current - sequence][constraint][increasing / decreasing][mask].
Index — This shows the length of the number formed.
previous — This is used to store the last digit used.
size - of - current - sequence — This shows the size of the current sequence. It has to be less than K.
constraint — This shows whether the current number formed is constrained or not.
increasing / decreasing — This is used to know whether we are currently making an increasing or decreasing sequence.
mask — This is used to take care of the condition that given M digits occur at least once in the number.
This is a geometry problem which can be solved using rotating line sweep algorithm. We iterate over all the lines(targets) and for each end of that line we will calculate and store the angle of all the other endpoints of the (n - 1) other targets.
And we will sort these values according to the angle. Then we will rotate the line passing through P by iterating over the other points, in slope order (We have already sorted it in slope order). If we encounter the first end of some target then we will add the length of that target to our current point and as we reach the other end we will subtract the length of that line from our current point. We have to perform the same for all the n given targets. We have to perform the same and take the maximum also we have add 1 when we reach the first end of some target to count the number of targets and as we reach the other end subtract 1 and in this way we can count the number of targets required to be destroyed to get current points.
The time complexity would be O(n * n * log(n)). The first n comes from iterating over all the n targets and the n * log(n) factor comes from storing the angle and sorting it.
The problem can be broken down into the following formulae which can be pre computed. (C(a, i) * C(b, j)) * (2c - 1)), j < i
where, C(x,y) represents x!/((x-y)!*y!)
Complexity -- O(t * a * b) where t, a, b are test case, value of A, value of B respectively.
Traverse the given string and try to find the letters 'c' 'o' 'd' 'e' 'r' 'e' 'd' in order. As you as you get the last letter break the loop and your answer is 'yes'.
If you reach the end of the string and cannot find all the letters then your ans is 'no'.
Complexity -- O(t * n) where t and n are test case and length of string respectively.
It was based on Matrix Exponentiation. The initial matrix to be formed will be a 64 * 64 matrix, where we store the number of ways to go from a 4 letter state to another 4 letter state, keeping in mind all the restrictions.
However, this matrix with 104 test cases will lead to TLE, with total operations being 104 * (643log n).
Hence, with the solutions to initial values, one can solve the linear equations using any method say Gauss Elimination, and obtain a much smaller 3 * 3 matrix, thereby reducing the number of operations to 104 * (33log n)
It was based on DP on trees.
dp[source][m] will store the length of the longest path starting from source under these 3 cases -
a) m = 0 : The path will begin from the node source, go via the subtree and return back to source itself.
b) m = 1 : The path will begin from the node source, and ends in a node which if part of subtree of source.
c) m = 2 : The path begins in a node in subtree of source, passes through source, and ends in another node in subtree of source.
These difference values had to be stored for each node, and max of all of them shall be the final answer.
Upd 3:- The Editorials for the problems are here. We will add for the remaining 2 problems in few hours.