很有可能是设置了全局变量的原因。
官方解释:
First, please check if you are using any global or static variables. They are Evil, period. If you must declare one, reset them in the first line of your called method or in the default constructor. Why? Because the judger executes all test cases using the same program instance, global/static variables affect the program state from one test case to another. See this Discuss thread for more details.
根据以上提示,修改代码,尽量不使用全局变量