I was giving online exam on hackerearth. The problem statement is
Note: It has already ended few days back.
# | User | Rating |
---|---|---|
1 | ecnerwala | 3648 |
2 | Benq | 3580 |
3 | orzdevinwang | 3570 |
4 | cnnfls_csy | 3569 |
5 | Geothermal | 3568 |
6 | tourist | 3565 |
7 | maroonrk | 3530 |
8 | Radewoosh | 3520 |
9 | Um_nik | 3481 |
10 | jiangly | 3467 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
2 | adamant | 164 |
4 | TheScrasse | 159 |
4 | nor | 159 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 150 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
Name |
---|
At first, I thought of using polynomial rolling hash function. But since we have integral values, there will be high probability of collision. So, couldn't able to verify its truthfulness.
I can't come up with a better solution, but I think you can use suffix array to compare 2 substrings in O(log(n)) instead of hash. Nevertheless, hash still works pretty well if you use 2/3 mods. (and seems to be easier to implement too?)
I solved it using the above solution during contest and it passed all tests :)
In the contest, I submitted a brute force solution and even that passed, which means that test cases were quite weak.
Very true, I was doubtful that hashing would work, then I thought oh wait I am on hackerearth not on codeforces, walla ac, lol.
Still I guess double hashing or triple hashing would reduce the collision probability.