确保你关了longlong,然后定义数组大小为 2×1072 \times 10^72×107,亲测可过。
#define N 20000005 #define INF 1e18 using namespace std; struct tree{ int ls,rs,v; }t[N];