This Question logic implemenation is easy , but as test case is very large so it is not able to pass in 2 seconds even after Meomizing the answer.
Images :
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
This Question logic implemenation is easy , but as test case is very large so it is not able to pass in 2 seconds even after Meomizing the answer.
Images :
Name |
---|
Auto comment: topic has been updated by silenttkillerr (previous revision, new revision, compare).
This problem can not be solved.
why? . This asked in Paypal interview
You have to write the problem for people to solve it.
Auto comment: topic has been updated by silenttkillerr (previous revision, new revision, compare).
Auto comment: topic has been updated by silenttkillerr (previous revision, new revision, compare).
There are up to 2 parts of each sequence of events 1) ball is passed around without entering a cycle 2) eventually the ball will enter into a cycle for large number of passes. Proof: if there are more passes that people, then some person must receive the ball more than once by pigeon hole principle.
You need to handle both cases elegantly. The cycle part needs to be handled with modular arithmetics.
so we just figure out the cycle size and check if the number of passes in the questions is below that or above that and give the ans using modular arithmetics right?
Yep, you got it! Also note that the cycle may not start on the first person so you need to handle that too.
i don't get how these questions seemed so damn hard when i was giving company online assessments, but now they seems like a breeze lol