Maximum sub segment sum
Maximum sub segment sum
Problem: given the sequence a[1],a[2],a[3],..., a[n] composed of N integers (possibly negative numbers), find the maximum value of the sum of sub segments of the sequence such as a[i]+a[i+1] +... + a[j]. When all the given integers are negative, the sub segment sum is defined as 0. According to this definition, the optim ...
Posted by spiffy577 on Tue, 09 Nov 2021 01:54:08 -0800
Weighted union search set
A basic union search set
There are only two operations for the basic union query set, one is to find ancestors, and the other is to merge
int find(int x)
{
if(x==pre[x]) return x;
else return pre[x]=find(pre[x]);
}
void join(int x,int y)
{
pre[find(x)]=find(y);
}
Two weighted union search set
for weighted concurrent sear ...
Posted by Stevis2002 on Wed, 03 Nov 2021 12:48:17 -0700