Hello Codeforces community!
I am glad to announce that HackerRank 101 Hack 26th edition will be held on 23rd June 2015 at 16:30 UTC. You can sign up for the contest here.
The problem statements will be available in English and Chinese. Though what's priceless is solving interesting problems and the thrill of competition, prizes make the competition fierce. Top 10 performers will get a HackerRank T-shirt.
Problems have been set by me(darkshadows) and tested by wanbo. The contest will consist of 5 problems with variable scoring distribution. I have tried my best to set a balanced problem set. Hopefully everyone will enjoy. Also, you'll be able to enjoy the detailed editorials written by the setter.
Good luck and have fun!
UPDATE1 Scoring is 30 — 40 — 50 — 100 — 120.
Cumulative time taken to solve the challenge is used as a tie-breaker.
UPDATE2 Editorials for all problems have been enabled.
Clashes with CF Round 309 now :(
No more clash now ^_^
Day for CF Round 309 has been changed. 101 Hack will still happen at the announced time.
Starts in a few hours.
I love that you are looking forward to it. Hopefully you'll be able to enjoy the contest! I along with wanbo have given our best try to make a balanced and interesting problem set.
first three are too boring to solve and last two are too hard to solve — this contest was so unlucky for me:(
The first three are boring, but the last two are quite standard. Still I haven't managed to solve the fifth because I have spent too much time (about 40 mins) on the second problem lol.
Oh, at least I am not the only one :) I spend 50 minutes on 2nd, feel ashamed :)
In fact I don't agree with Neodym, I'd rather say that last 3 problems are boring (and standard), comparing to first two :)
I did not solve second one. Spent almost an hour on it... What is the idea behind? My code is here.
I can explain what I did .please be patient :P A- rotating ball . B is ball thrown from origin.
First I tried sending ball B at t=0. I found position of ball b at time =R (time taken by ball to reach at the circumference with thrown at time =0) if this position was in the first quadrant. Then optimal answer would be the one we get by throwing the ball B at t=0 answer in this was would be "R R%S/ gcd(R%S,S) / S/GCD(R%S,S).
if position of ball B at t=R is not in the first quadrant then answer would be "(r/s + (r%s):1?0)*s 0/1" because he can wait for some time t>0 and then throw the ball such that it collided at R,0
What's wrong with this approach for 2nd : - r=r%s. if(r belongs to 0..s/4) print r/gcd(r,s) "/" s/gcd(r,s) - otherwise print 0/1 explanation : if r through at t=0 can reach a place in the first quadrant than do so . otherwise it can r,0 point in the next cycle
lets have a good laugh shall we :P .For 2nd I though the answer was of for "testcase_number fraction" :P XD
editorials?
See the update2. They have been enabled.
I am kinda new in hackerrank and could not find the editorials.
Can you(/anyone) tell me how can I find them?
thanks bro.
Almost did task no.4. Suffix-Array + Lcp + Fenwick tree + Mo's algorithm. code However, getting TL... :(
Suffix-Array + lcp is enough.
My solution was an overkill. I used suffix+lcp+2seg trees.
Can you explain your solution?
In fact it is not that bad, I would not call it an overkill. Constraints are loyal, so I did the same, but using hashes.
With hashes you can compare two substrings in O(1), this gives you LCP with bin.search only, this gives you SufArray with "LCP+comparing next char" comparator; and instead of using seg.tree of pairs / two seg.trees you may use two Fenwick trees, and code becomes even simpler.
For each index i lets find such f[i], that s[i..f[i]] is unique substring, and s[i..f[i] - 1] is not. That can be done in using suffix-array and lcp. Note, that f[i] is non-decreasing sequence. Really, s[i + 1..f[i] - 1] is substring of s[i..f[i] - 1], so it is non-unique.
Now, for each query we can answer in : we'll find first segment i..f[i], which intersects with r, let it be q (q=upper_bound(f, r)). Now it's easy to count number of non-unique subsequences in s[l..r]: it's . That's because for all indicies x < q: f[x] < r, and for indicies x > q: f[x] > = r.
May be I missed + 1 or - 1 somewhere, but I hope that you can get the idea.
Thanks, nice solution.
Haven't figure out it during contest... can you help me with it?
SA + MO works fine.
I did Suffix-Array + Lcp + Fenwick tree + Mo's. :) but getting TL sometimes. Can you share your code?
So, O(Nlog2N) and were supposed to pass, probably your solution has an extra O(logN) factor?
yep, it does :(
Code
Is there any problem in using Math.floor(1 + Math.log10(number)) to get the digit length? My one test case failed in 3rd question due to that.
Is there any edge case in 5th question? I got a seg fault on 3 test cases.
I think it may be due to recursion depth. One of such test cases was a linear graph.
Stack limit is around 106. So, I think there might be some other issue.
For 3rd what should be the output for 1 53959375 29374943
79999999
It is just me or everyone felt that 3rd was quite easier than 2nd ? :P
Edit : I did it with O(17) ad-hoc solution per test case.
The 3rd problem was indeed a piece of cake with DP.
How to solve via DP?
After I wrote the DP, I realized that you don't even have to do that. Once one number gets below its limit (that is, you use a digit lower than the limit), you can always get a 9 on the rest of the digits.
176 AC on second, 220 AC on third. I believe that difference would be even higher in case author swapped these tasks in a problemset — lot of people didn't even tried 3rd because of being unable to solve 2nd.
Fun fact: I earlier had intention of keep 2nd one as the 1st. But wanbo later told me that it might be a little difficult.
This made me wonder if HackerRank will ever decide on implementing Dynamic Scoring in short contests.
106 bytes for stack size? Are you seriously? Can you please increase it? As I know, it's a common practice.
I meant that its at least 106. I just found out its 8MB.
OK, 8MB. But it's not enough.
p.s. 256MB = codeforces stack size.