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 :
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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 :
Название |
---|
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