本文共 722 字,大约阅读时间需要 2 分钟。
并查集做,满了的水池合并为为最后一个为父节点
#include#include #include #include #define maxn 200010int n;int next[maxn];int v[maxn];int lft[maxn];/*union-findsomewhere change to your need*/void GxdUnionFindInit(int* gnum,int glen){ for(int i=0;i =lft[x]&&x!=n) { p-=lft[x]; lft[x] = 0; GxdUnionFindAdd(next,n+1,x,x+1); x = next[x]; } lft[x]=std::max(lft[x]-p,0); GxdUnionFindAdd(next,n+1,last,x); }else { int k; scanf("%d",&k); if(lft[k]==0) printf("%d\n",v[k]); else printf("%d\n",v[k]-lft[k]); } } return 0;}
转载地址:http://oggci.baihongyu.com/