线段树正确思想9分求助

P4513 小白逛公园

wwhOvO @ 2020-08-10 19:26:08

code: https://www.luogu.com.cn/paste/22ojklsr

连这题都不会做了 /kel


by Catalan1906 @ 2020-08-10 19:31:52

@WuWenhao

#define int long long

int main() -> signed main()

试试?


by wwhOvO @ 2020-08-10 19:33:41

@Catalan1906 还是不行 /kel


by Werner_Yin @ 2020-08-10 19:35:07

@WuWenhao update 函数的第二行应改为:

t[p].lmax = max(t[p * 2].lmax, t[p * 2].sum + t[p * 2+1].lmax);

by wwhOvO @ 2020-08-10 19:37:54

@Werner_Yin 还是不行诶 /dk


by Werner_Yin @ 2020-08-10 19:38:08

@WuWenhao 另外,您处理l>r时应该这样写:

if(left > right) swap(left,right);

by wwhOvO @ 2020-08-10 19:40:49

@Werner_Yin 改了一下l>r那里就通过了

我怎么会犯这种sb问题


|