RT ,如果你把两个临时数组的top设成全局变量,如:
topl = topr = 0;
for (int i = ldom; i <= rdom; ++ i)
{
ll temp = 0;
for (int j = head[p[i].id]; j != -1; j = nxt[j])
{
if (temp > p[i].p) break;
temp += t.ask(to[j]);
temp += t.ask(to[j] + m);
}
if (temp >= p[i].p) ++ topl, tmpl[topl] = p[i];
else p[i].p -= temp, ++ topr, tmpr[topr] = p[i];
}
那么你会在递归的时候改变topl的值,然后造成一些莫名其妙的错误,并因此 WA/TLE