[BZOJ3872][Poi2014]Ant colony】的更多相关文章

[BZOJ3872][Poi2014]Ant colony 试题描述 There is an entrance to the ant hill in every chamber with only one corridor leading into (or out of) it. At each entry, there are g groups of m1,m2,...,mg ants respectively. These groups will enter the ant hill one…
正解:二分+$dp$ 解题报告: 传送门$QwQ$ 一年过去了依然没有头绪,,,$gql$的$NOIp$必将惨败了$kk$. 考虑倒推,因为知道知道除数和答案,所以可以推出被除数的范围,然后一路推到叶子节点就成$QwQ$ $over$ 嗷注意一个细节是有可能乘爆,所以每次和$m_max$取个$min$就成$QwQ$ #include<bits/stdc++.h> using namespace std; #define il inline #define gc getchar() #defin…
[BZOJ3872][Poi2014]Ant colony Description 给定一棵有n个节点的树.在每个叶子节点,有g群蚂蚁要从外面进来,其中第i群有m[i]只蚂蚁.这些蚂蚁会相继进入树中,而且要保证每一时刻每个节点最多只有一群蚂蚁.这些蚂蚁会按以下方式前进: ·在即将离开某个度数为d+1的点时,该群蚂蚁有d个方向还没有走过,这群蚂蚁就会分裂成d群,每群数量都相等.如果d=0,那么蚂蚁会离开这棵树. ·如果蚂蚁不能等分,那么蚂蚁之间会互相吞噬,直到可以等分为止,即一群蚂蚁有m只,要分成…
[BZOJ3872]Ant colony(二分,动态规划) 题面 又是权限题... Description There is an entrance to the ant hill in every chamber with only one corridor leading into (or out of) it. At each entry, there are g groups of m1,m2,...,mg ants respectively. These groups will ent…
3872: [Poi2014]Ant colony Time Limit: 30 Sec  Memory Limit: 128 MB Description   There is an entrance to the ant hill in every chamber with only one corridor leading into (or out of) it. At each entry, there are g groups of m1,m2,...,mg ants respecti…
Ant colony bzoj-3872 Poi-2014 题目大意:说不明白.....题目链接 注释:略. 想法:两个思路都行. 反正我们就是要求出每个叶子节点到根节点的每个路径权值积. 可以将边做为代理根.或者将边断掉. 最后,附上丑陋的代码... ... #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; t…
题目大意: 给定一棵$n(n\le10^6)$个结点的树.在每个叶子结点,有$g$群蚂蚁要从外面进来,其中第$i$群有$m_i$只蚂蚁.这些蚂蚁依次爬树(一群蚂蚁爬完后才会爬另一群),若当前经过结点度为$d+1$,蚂蚁数量为$m$,则接下来没走过的$d$个方向,每个方向爬$\lfloor\frac md\rfloor$只蚂蚁,剩下蚂蚁消失.在给定的一条边上有一只食蚁兽,若当前经过这条边的蚂蚁数量为$k$,则吃掉这些蚂蚁.问最后能吃到多少蚂蚁? 思路: 从给定边出发BFS,算出每条边会被吃掉的蚁群…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3872 可以倒推出每个叶子节点可以接受的值域.然后每个叶子二分有多少个区间符合即可. 注意一开始的两个点不是直接是 l[ u ]=r[ u ]=lm !也要看度数的!且把那条边的两个端点分别算子树很方便. 而且过程中似乎会爆 long long ,所以如果 l[ i ] 都大于最大值就不往下算了:r[ i ]也要每次与最大值取min. 然后是和网上一份题解对拍出错却仍A了此题的代码.不想管是…
啊我把分子分母混了WA了好几次-- 就是从食蚁兽在的边段成两棵树,然后dp下去可取的蚂蚁数量区间,也就是每次转移是l[e[i].to]=l[u](d[u]-1),r[e[i].to]=(r[u]+1)(d[u]-1)-1,这里注意当l>maxm的时候就return,不然之后的没有贡献而且会爆long long 然后把每个dp到的叶子都二分一下看他的贡献区间里有几群蚂蚁加进答案里最后乘上k即可 #include<iostream> #include<cstdio> #inclu…
Luogu3576 POI2014 MRO-Ant colony The ants are scavenging an abandoned ant hill in search of food. The ant hill has nn chambers and n-1n−1 corridors connecting them. We know that each chamber can be reached via a unique path from every other chamber.…