I was giving online exam on hackerearth. The problem statement is
Note: It has already ended few days back.
# | User | Rating |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 161 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 152 |
8 | pajenegod | 146 |
9 | BledDest | 144 |
10 | Um_nik | 143 |
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.