Problem link: 1661B - Получение нуля submission: 208009051 I tried to solve this problem using the dfs algorithm. But I can't still configure what is causing the MLE verdict. Help if someone can.
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
Problem link: 1661B - Получение нуля submission: 208009051 I tried to solve this problem using the dfs algorithm. But I can't still configure what is causing the MLE verdict. Help if someone can.
| Name |
|---|



I don't see how you dfs must ends, for me it is infinite recursion at first glance
At a particular position, any number will be divisible by 32768(2^15) and have a value equal to zero. As the value is not equal to -1, that will end the recursive call.
You have test input
Why don't we try it?
x = 19, produces two inner calls (dfs(38)anddfs(20))dfs(38)produces another two inner calls (dfs(76)anddfs(39))dfs(76)producesdfs(152)anddfs(77)x = 16384. This will producedfs(0)anddfs(16385)dfs(0)indeed returns 0, butdfs(16385)? Moving ondfs(16385)producesdfs(2)anddfs(16386)dfs(2)producesdfs(4)anddfs(3)x = 16384See problem? If not, then your inner dfs calls never terminates.
That's too deep! Thanks. But how can I handle this case?
I don't think that dfs approach works here (at least I don't know any proof for it). I'd do just simple bfs from zero to all values by reversed operations.