USACO 1.3.1 mixed milk JAVA TreeMap to solve the timeout problem

You may think that the timeout of this question is caused by the tree. If your code only has general tree building and traversal operations, then the tree is actually innocent. The problem is Scanner.

Please refer to this article to solve the problem of Java running timeout in OJ-AdamLeeXi , here is a detailed introduction to the time efficiency difference between Scanner and BufferedReader (there is a big difference).

I can’t remember what I said in class, but the basic logic is that you need to use a StringTokenizer to receive the result of BufferedReader.readLine(), and StringTokenizer can be converted to String type, and then use to convert the string to int .

Guess you like

Origin blog.csdn.net/roswellnotfound/article/details/109121518