First step in getting the questions was to look at the first question and roughly scan the water question. I thought it was a hash, and after thinking about it further, the hash didn't work. I found that you can use set, so I took set and knocked it out, and the samples were all right.
Second question, looked at the sample and thought it was DFS. actually looked at it and realized it was simulation. Complexity O(k). After writing according to the topic, I measured the sample, the first answer is right, the second output 14. After looking at the sample for a long time, I realized that I need to check the weight, and I used a vis array to mark it. The first answer was right, the second output was 14. After looking at the sample for a long time, I realized that I had forgotten to reset the vis array and changed it, and the sample was correct.