Because this problem is simple (thinking), but it is still complicated to do, so I can only briefly talk about the idea of solving the problem. I don't care, I just hope I can help you.
You can ask me directly if you have any questions, QQ: 15890622 18.