CodeForces 1025G Company Acquisitions】的更多相关文章

题意 描述有点麻烦,就不写了. \(\texttt{Data Range:}1\leq n\leq 500\) 题解 势能函数这个东西好神啊-- 这个题目用常规的 DP 好像做不出来,所以我们可以考虑设计一个函数将一个局面到最终局面的期望进行评估,如果这个函数能够满足任意一次操作会使得函数值的期望增加 \(1\),那么就可以用最终局面的函数值减去初始局面的函数值就得到期望操作次数了. 同时,必须满足最终局面无法转移,因为有环的转移图比较难去算转移,这个时候势能函数就出来了. 这个题目中我们考虑设…
\(\mathcal{Description}\)   Link.   \(n\) 个公司,每个公司可能独立或者附属于另一个公司.初始时,每个公司附属于 \(a_i\)(\(a_i=-1\) 表示该公司独立).不存在两级及以上的附属关系.每次事件随机选取两个独立的公司,使其中一个公司所拥有的附属公司全部独立,并且该公司成为另一个公司的附属.求使仅存在一个独立公司的期望操作次数.对 \(10^9+7\) 取模.   \(n\le500\). \(\mathcal{Solution}\)   奇怪的…
题目链接:https://codeforces.com/contest/1090/problem/A A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to s…
Description The company \(X\) has \(n\) employees numbered from \(1\) through \(n\). Each employee \(u\) has a direct boss \(p_u\) \((1 \le p_u \le n)\), except for the employee \(1\) who has no boss. It is guaranteed, that values \(p_i\) form a tree…
从这里开始 题目列表 瞎扯 Problem A Doggo Recoloring Problem B Weakened Common Divisor Problem C Plasticine zebra Problem D Recovering BST Problem E Colored Cubes Problem F Disjoint Triangles Problem G Company Acquisitions 瞎扯 打比赛,发现自己特别菜. 居然还苟且水上紫名 这个号不敢玩了.要努力学习…
传送门 D. Restructuring Company time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Even the most successful company can go through a crisis period when you have to make a hard decision — to rest…
B. Kefa and Company Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/problem/B Description Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend wi…
http://codeforces.com/contest/794/problem/C Description Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the…
E. MST Company time limit per test 8 seconds memory limit per test 256 megabytes input standard input output standard output The MST (Meaningless State Team) company won another tender for an important state reform in Berland. There are n cities in B…
E - Company 思路: 首先,求出每个点的dfs序 然后求一些点的公共lca, 就是求lca(u, v), 其中u是dfs序最大的点, v是dfs序最小的大点 证明: 假设o是这些点的公共lca, in[o]是o的入时间戳, out[o]是o的出时间戳, 那么对于任意一点x, in[o] <= in[v] <= in[x] <= in[u] <= out[o] 所以o是x的祖先 所以o是这些点的公共lca 所以只要求出每段区间的dfs序最大的和最小的, 删除的要么是最大的,…