### malcolm's blog

By malcolm, 5 years ago,

Hey, guys!

I'm excited to invite you to participate in 101 Hack June 2016! The contest will start at 16.30 UTC, June 20.

I'm the problemsetter of this round. You may have seen my tasks on previous HackerRank contests or may have participated in Codeforces Round #319 (Div. 1) or Codeforces Round #319 (Div. 2).

There will be five tasks and two hours for you to solve them. Top-10 contestants on the leaderboard will receive awesome HackerRank T-shirts! (I'm really jealous, since I don't have one)

I'd like to thank wanbo for his invaluable help and testing all the problems, danilka.pro for testing one of the problems and his cool proof of author's solution, Zlobober for his help in estimation of one of the tasks difficulty, and sankear, he did nice job sitting in the bar with me and discussing the problems.

I hope you will enjoy the tasks. Please read all of the problem statements during contest, as it may be essential for your final place.

Good luck!

UPD. The contest has ended. Special congratulations to Lewin: the only contestant who solved the last task!

Top-10:

1). Lewin

3). Errichto

4). tourist

5). Temirulan

6). Kostroma

7). Deemo

9). uwi

10). mgch

• +128

 » 5 years ago, # |   +145 Sitting in a bar and talking about problems... I thought it's only a dream, sometimes shown in Hollywood movies.
•  » » 5 years ago, # ^ |   +41 Wtf? Isn't that like a completely typical thing :P? We already ate burgers and talked about problems, I guess it wouldn't have made much difference if that had been bar :P. Also don't tell me you haven't discussed about ACMs and algo problems at some alco parties :P.
•  » » » 5 years ago, # ^ |   +42
 » 5 years ago, # |   +70 The problem set is in very high quality, I like it very much. And it is relatively a little harder than previous contests.
 » 5 years ago, # |   +64 Guys, the contest starts in one hour. Don't miss it!
 » 5 years ago, # |   -8 The site is down -__- :/
 » 5 years ago, # |   +70 LOL an epoch time bug post-contest xD
 » 5 years ago, # |   +5 It's a pity that in last problem both cubic and quadratic solutions give the same number of points
•  » » 5 years ago, # ^ |   +2 You've got too great cubic solution, mine received only 27.50 points. BTW, good problems, but I've seen something similar to D in some Petrozavodsk training camp.
•  » » 5 years ago, # ^ |   +6 Yeah, that was a pity to see cubic solutions getting ~50 pt. Author's cubic solution is much slower and gets ~25 pt, as expected.
•  » » » 5 years ago, # ^ |   +5 Well, setting n<= 5000 for quadratic solution would probably help, 1000^3/6 is not undoable :)Thanks for good problemset
 » 5 years ago, # |   0 How to solve the third problem?
•  » » 5 years ago, # ^ |   0 You may find the solution in the "editorial" tab on HackerRank.
•  » » » 5 years ago, # ^ | ← Rev. 3 →   +19 By the way, did you came up only with a solution which finds the k-th element but not the whole array, or intentionally make this problem slightly easier?
•  » » » » 5 years ago, # ^ |   0 How do you find the whole array!?
•  » » » » 5 years ago, # ^ |   0 I have no idea, how to find the whole array. Could you briefly describe your solution?
•  » » » » » 5 years ago, # ^ | ← Rev. 3 →   +29 At first find for every segment [li;ri] the sequence of segments [li, ri], [lj0, rj0], [lj1, rj1], ..., [ljk, rjk] such that i < j0 < j1 < ... < jk, and ljk is minimal possible. This can be done by segment tree by processing the segments in reverse order (we need only the value of ljk).Then for each position pos find the minimal such ljk for all [li, ri] containing pos. Then process apos in the order of increasing apos, the position of it will be the first free positon after such ljk.
•  » » » » » » 5 years ago, # ^ |   +51 I must misunderstand what you mean..Say you have initial array 10 11 12 0 1 with the segments 2 4 and 0 2. Then from what I understand, for any position in the array, we find ljk = 0? But then we'd conclude that value 0 goes to position 0, then value 1 goes to position 1, but really it will go to position 3.
•  » » » » » » » 5 years ago, # ^ |   +56 It seems you are right, and my solution is a bullshit =) The tests were not strong enough :)
 » 5 years ago, # |   0 https://www.hackerrank.com/contests/101hack38/challenges/sorted-subsegments can anybody suggest an alternate approach to solve this problem?? the one described in editorial was like magic to me.. any intuitive approach by anyone please??
 » 5 years ago, # |   +19 It was also a pity that in the third problem brute force in java (sort each sub-segment) got > 72 pts...
•  » » 5 years ago, # ^ |   +8 In c++ it only gave 20 pts, Why is that?
•  » » 5 years ago, # ^ |   +8 That can't be true!
•  » » » 5 years ago, # ^ |   +9
•  » » » » 5 years ago, # ^ |   0 Can you share why binary search is valid. The editorial explains little about this.
•  » » » » » 5 years ago, # ^ |   0 I'm not sure I've understood your concern.We ask if value v at position k after Q queries is >= x. If that is true, then it is also true that v > x-1, x-2, .., 1. Hence the binary search is valid.
•  » » 5 years ago, # ^ | ← Rev. 2 →   +5 Agreed. Naive solutions using built-in sorts should NOT be worth > 90% credit. That was ridiculous and one of the major defects of this contest.Furthermore, the very same naive solution in C++ only gave 20 points compared to java's 72. That's also a very, very interesting outcome. What are the underlying implementation differences between the builtin sort functions of the two languages, and are those differences (if any) accountable for the massive runtime difference? If not, is there some other factor that I'm not seeing here (other than I/O which I believe is a trivial factor given the low input constraints)?
•  » » » 5 years ago, # ^ |   +40 In java8 sort is TimSort which works good for almost sorted segments
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   +10 :'(i cri evrytim (pun intended)
•  » » » 5 years ago, # ^ |   0 We do not know Java's sort method is so fast for almost sorted array, the c++ solution only got 20+ pts. https://www.hackerrank.com/contests/101hack38/challenges/sorted-subsegments/submissions/code/6063903
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 Another naive solution that gives high score of 67.10 Codeint main() { //readf int n , q , k; ui min = -1 , max = 0; scanf("%d %d %d" , &n , &q , &k); long* a = new long[n]; long inp0 , inp1; fo(y , n)scanf("%ld" , &a[y]); fo(y , q) { scanf("%ld %ld" , &inp0 , &inp1); if(inp0max) max = inp1; } sort(a+min , a+max+1); printf("%ld" , a[k]); } 
•  » » » 5 years ago, # ^ |   +17 It's not naive — it's incorrect one :/
•  » » » » 5 years ago, # ^ |   0 Even though this solution is glaringly incorrect, HackerRank's partial credit system awards it 67.1 points because it passes a lot of test cases.That's where their grading system falls short.
 » 5 years ago, # |   +11 Nice editorial of third problem. Thanks! But isn't the complexity O(Q·(log(N))2) instead of O(N·(log(N))2) ?
 » 5 years ago, # |   0 One thing that I really don't like about hacker rank is that only 480 people had correct solution and yet my rank is 779.That makes me not care about hacker rank rating . They always have a different and nice kind of problem set but these little things, I don't like them. On the other hand it allows some people who know a concept to good extent might get some edge over other , there won't be a binary game , but this is often mis-used.IMO constraints must be set such that only solutions with very good knowledge gets some points.
•  » » 5 years ago, # ^ |   0 Well,It's all about testing. They can add the number of test cases to solve per run. This way even to get a partial score, your solution would have to be correct.Also they can exclude some edge cases if they want to provide partial score for not covering all the cases.Anyway — the partial score system is more fair in my opinion. You do your best on all the problems and if you have a small bug or you miss one case, you can still get decent credits.It also allows you to develop a better strategy to get a higher rank. You can decide whether you will try to spend more time on solving some problem completely or maybe it is better, to write a brute force and move on to the next task.
•  » » » 5 years ago, # ^ |   +10 I'd say that the partial score system actually isn't very fair, in some cases.Try submitting a program that only prints 1 to the last problem, "Byteland Itinerary". Because you pass a few test cases with that, you get 4 whole points.For example...Consider person A, who solved the first two questions very quickly but doesn't know how to solve the rest. Person A gets 50 points and is very much ahead of other 50 point people because he solved them more quickly. Person B takes forever to solve the first two, gets 50 points, and then submits a print 1 program to the last problem, netting a total of 54 points, and beating person A.Person B doesn't deserve to be ahead of person A. This is where HackerRank's partial credit grading system fails.
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   0 Well,They could add T — the number of test cases to solve.Then they could add 10 small tests with different answers and printing 1 wouldn't score anything — as I said it is all about testing.They have a big potential of preparing such a set of tests which will give different scores for different approaches. It is not the problem of partial scoring, but testing.Anybody who has an idea which will get positive score on any task should get the higher position than somebody who has no idea at all. The fact how easy will it be, to get that partial score depends only on the tests.
•  » » » » » 5 years ago, # ^ |   -10 Good points.I think the best way to rectify the issue I mentioned earlier is to only allow judge submissions if and only if the sample tests pass successfully (hackerrank's run tests button). Also, the sample tests should not be included for grading towards actual points.
•  » » » » » » 5 years ago, # ^ |   +15 That's not a solution, one can simply write a couple more if/else statements to pass the sample. Adding some number of test cases as mentioned above is the only way I can think of.
•  » » » » » » » 5 years ago, # ^ |   0 Never mind, you're right. I didn't really think things through.
•  » » » » 5 years ago, # ^ |   +21 In a partial scoring system, the best solution according me is to have subtasks and not marks per test case. For example a person solving a smaller subtask should get full marks for that subtask if they solve it completely otherwise 0. This individual mark per test case actually rewards you for wrong solutions.A smaller subtask, ensures that a person has atleast solved the problem 100% for those particular constraints.
•  » » » 5 years ago, # ^ |   +32 The most unfair thing IMO about partial scoring is that the range of possible points a solution can get is continuous. This means that some optimisations like reducing constant factor of solution can make some tests of higher subtask pass, and award more points for almost the same solution.For more complicated problems/codes, it then becomes a matter of chance which subtasks marginally pass/fail for which user. You can already see the wide variety of naive/wrong solutions for sorted-subsegments which got >=45 points. Different users might get a large variety of scores, with only a few users with partial solutions getting equal scores, and it beats the purpose of time-based penalty. This could be observed in this contest's ranklist as well.This can be avoided by awarding subtask-based points (like is done in Codechef Long).Also, i don't see any point in awarding even a small number of points for a very naive brute solution for the difficult tasks.
 » 5 years ago, # | ← Rev. 2 →   +66 And it was also a pity that organizers were giving hints to some contestants during the contest:https://www.hackerrank.com/contests/101hack38/challenges/points-on-a-line/forum/comments/145470I don't understand such a behavior. If you wanted everyone to pass the first problem, you could have asked to print 1 for example.Otherwise it is unfair for other contestants who didn't think of reading discussions during the contest.Edit: That comment is just explaining the solution... https://www.hackerrank.com/contests/101hack38/challenges/points-on-a-line/forum/comments/145418
•  » » 5 years ago, # ^ |   +8 Because there are hundreds of very beginners in our platform, they do not have any experience in problem solving, we hope we can guide them to get their first AC. This is only permitted for the 1st challenge. If just output 1, very beginners will also feel so stupid. Hope you can understand, there are hundreds of people still not passed even at the ends of the contest, and they will email to us complain about it. So we changed our strategy that we need to help them during the contest for the first challenge. Everyone will be excited by their first AC, maybe because of these, several years days, they will be red coders. :) Someone with weak mind will may leave because of too many WAs even they are convicted that their solution is correct.
•  » » » 5 years ago, # ^ |   +46 ... there are hundreds of people still not passed even at the ends of the contest, and they will email to us complain about it.So the lesson is: if you are lazy as fuck to improve, then complain about being lazy as fuck and get a free AC. Maybe that's the reason why there's a bunch of indian competitive programmers but only a few have decent skills.
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   +20 Chill, dude.BTW I think you're going to need some burn heal.
•  » » » » » 5 years ago, # ^ | ← Rev. 3 →   +6 I'm just saying that if you are lazy to improve, accept your position and don't complain. But asking for hints during a contest is just stupid.And if you feel offended for what I said about the indians, then read wanbo's comment. If there are hundreds of guys not able to solve an easy problem and only worried about getting an AC during contest, what can you expect from them in the future? Nothing, because they probably just don't even care about competitive programming and do contests only to improve her resumes or to pass a job interview.
•  » » » » » 5 years ago, # ^ |   +8 This hand looks as mine after yesterday crash from bike. I fell down while I was driving up the hill :D
•  » » » 5 years ago, # ^ |   +54 So it is official — in case I'll struggle with solving first problem next time, I can ask you about solution right during a contest? :)
•  » » » » 5 years ago, # ^ |   -28 yes, and we will allow gray coders to help you solve.
•  » » » » » 5 years ago, # ^ |   +13 This is like giving somebody a lollypop just because they cry foul about failing in the exam. That lollypop has to be earned only in the case of passing the exam and let everybody else know there is no other way around it.
•  » » » » » » 5 years ago, # ^ |   0 Inspiring :')
•  » » » 5 years ago, # ^ | ← Rev. 2 →   +68 I wish I knew this before Hourrank 9.It took me 45 minutes to solve the first task as I couldn't proof the simple greedy solution. On the other hand the second task took me 5 minutes.Next time I will be smarter and just use the discussions tab :)
•  » » » 5 years ago, # ^ | ← Rev. 3 →   +6 More seriously.I think that you can add a notice to the problem that this is a competitive programming contest. It is not practice problem and doesn't mean to be an easy challenge. Please do not send us any email if you don't get accepted during the contest. After the contest there will be a published editorial and you will have the opportunity to check the solution and test cases. Don't be upset, don't give up, try hard and maybe next time you will succeed — or something like that. To make sure that you don't upset beginning contestants and to show that you think of them and would like them to improve.
•  » » » 5 years ago, # ^ |   +23 In contests with prizes I'm going to start from the second problem. After some time I will go back to the first problem. I'll go to comments and hope to maybe even find a ready solution (code). I'm allowed to do it, right?Also, are you planning to provide solutions for second problems in the future?
•  » » » » 5 years ago, # ^ |   -15 You guys are really overreacting on this. The first problem of this contest was too simple, only newbies would struggle to solve this. wanbo said that they will only help newbies by giving hints, if a problem is not that simple they would not give any hints.
•  » » » » » 5 years ago, # ^ |   +21 You don't participate in any contests and know better?Why was it too simple? Do you think that it should be harder? So why would they provide a solution in the comments?In some contest eventually the first question will be harder than organizers expected. But yeah, we are allowed do talk about a solution in the comments.
•  » » » » » 5 years ago, # ^ | ← Rev. 4 →   +46 Oh no, no one is overreacting.You see, this is the problem with HackerRank. Nobody knows what are the rules when participating. And worse, the rules keep changing from time to time (sometimes because of a glitch but whatever) and the changes are NEVER mentioned anywhere.No I will NOT memorize what are the time limits for C/C++ or Java. No I DO NOT know that penalty for 101 Hack is the sum of all submissions but for HourRank is the last time of submission. Don't you think it is more convenient for everyone if it is mentioned EXPLICITY in the contest dashboard? Hell it is even difficult to know if a contest is rated or not. Seriously, how hard can it be to make all these information easier for contestants to access?Regarding providing solution to the first problem, no matter what the rules are, I can respect them even if I do not like them. But the rules should be FAIR AND YOU SHOULD EXPLICITLY MENTION THEM BEFORE THE CONTEST. If you are going to provide hints/solution for the first problem in discussion, that's fine(though I think its lame). But please DO NOT discriminate whether the contestant is gray or red and DO NOT invent your own rules DURING the contest.I know my comments may sound a bit harsh but that's just my 2 cents and please don't get me wrong. I am also a problem-setter in HackerRank, it is a great platform and I appreciate the work you guys do. But it can be a lot better with some minor modifications. My apologies if my words hurt anyone.
•  » » » » » » 5 years ago, # ^ |   +18 To be honest, infomation on whether contest rated is on "contest" page
•  » » » » » » » 5 years ago, # ^ |   0 This is precisely my point. There is information regarding the time limit for all languages somewhere too. But none of these are easily accessible right? To see whether a contest is rated, you have to go to the "contest" page, click on the contest and then it will expand to show if its rated or not. Sounds too convenient for me.In my opinion, it is better to add every information like whether its rated or not, how are ties broken and other contest rules somewhere in the contest dashboard. And if they really want to provide beginners with hints and/or solution, its better to post them by creating a "Hints" sub-section in the problem page instead of using discussion forum. I guess everybody would be happy then :)
 » 5 years ago, # | ← Rev. 2 →   0 Solutions where a person sorts the whole array and returns the answer gets 41 points. Solutions in which a person just sorts the array in between the maximum index and minimum index of queries gives 78 points. What is the difference between a person who implements segment tree and gets 80 points and a person with a naive/incorrect solution gets 78 points.I mean hackerrank is just losing it's sheen because of this. People with incorrect solutions getting 78 points is literraly is unfair over the system. Please do introspect and see it in the eyes of a deserving candidate who feels unfair that others incorrect solution passes and his correct solution takes time.
 » 5 years ago, # |   +3 Nlog(N)*log(N) solution (binary search + lazy segment tree) giving TLE for some test cases for problem "sorted subsegments". is lazy not sufficient for this problem?
•  » » 5 years ago, # ^ |   +6 While doing binary search..sort the array and only take those values which are in array..
•  » » » 5 years ago, # ^ |   0 oh yes that clever optimization :) thanks it made my solution 2 times fast!
 » 5 years ago, # |   0 I've just noticed, that time scoring in 101 Hack and HourRank differs: HourRank: largest time of best submission of last problem 101 Hack: sum of times of best submissions of all problems But don't see any decription in scoring rules, is it correect?
•  » » 5 years ago, # ^ |   0 It is correct ! I think the first decision for HourRank was same penalty as 101 Hack, but it was mistake on the first round and it wasn't changed after it :D It should be mentioned somewhere, but after 40 rounds I think everyone knows rules :)