尝试开启输入输出流同步(即删去ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);),我也不知道为什么。
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);