G - Green-Red Tree Gym - 102190G】的更多相关文章

题目链接:http://codeforces.com/gym/102190/attachments 题解:我们先将前5个点分别涂上红色或者绿色,使得这两棵树在5个点中都是连通,并不存在自环(建边方式不唯一,主要看自己怎么想的,只要满足题意即可).那么从第6个点开始:分别找一个固定的点与该点连边即可. 自己看别人做的方法,才自己做出来的,也是思考了一下,下面来张自己手动模拟的图,自己模拟一遍就会了呀 #include<bits/stdc++.h> using namespace std; int…
G.Code the Tree Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 35  Solved: 18 [Submit][Status][Web Board] Description A tree (i.e. a connected graph without cycles) with vertices numbered by the integers 1, 2, ..., n is given. The "Prufer" code…
题意 There is a tree with \(N\) vertices numbered \(1\) through \(N\). The \(i\)-th of the \(N−1\) edges connects vertices \(a_i\) and \(b_i\). Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing t…
AT2377 Blue and Red Tree 法一:正推 红色的边在蓝色的树上覆盖,一定每次选择的是覆盖次数为1的边的覆盖这条边的红色边连出来 覆盖次数可以树剖找到 这条红色边,可以开始的时候每个红色边的编号打标记到线段树节点的vector里 找一个覆盖次数为1的边的时候,沿途的vector不断弹出已经连出的红色边,一定会找到有且只有一个红色边 链的覆盖次数--,标记这个红色边已经连好. 法二:倒推在Ta的博客查看 最后连的一定是一个红色和蓝色的重(chong)边 不断找重边,然后缩点,(u…
Marge is already preparing for Christmas and bought a beautiful tree, decorated with shiny ornaments. Her Christmas tree can be represented as a complete binary tree composed of N nodes, numbered from 1to N and rooted on node 1. Each node has an inte…
In the mathematical discipline of graph theory, the line graph of a simple undirected weighted graph G is another simple undirected weighted graph L(G) that represents the adjacency between every two edges in G . Precisely speaking, for an undirected…
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11670&courseid=0 题目大意: N条开口朝下的抛物线T = -aR2 + bR + c,求哪条抛物线最高的点最高. 题目思路: [模拟] 直接取x=b/2a带入抛物线计算最高点记录答案. // //by coolxxx //#include<bits/stdc++.h…
Description 给定一棵\(n\)个节点的蓝边树,再给定一棵\(n\)个节点的红边树.请通过若干次操作将蓝树变成红树.操作要求和过程如下: 1.选定一条边全为蓝色的路径: 2.将路径上的一条蓝边断开,并将路径的两个端点之间连一条红边. 问能否实现目标. Solution 我们发现这个过程只会做恰好\(n-1\)次,因为每次都会减少一条蓝边.增加一条红边. 考虑红树上的一条边\((u,v)\),显然在蓝树上操作时,我们选择了一条以\(u\)和\(v\)为端点的路径,才造就了这条边.因此红树…
之前两次遇到过函数的思想的题,所以这次很敏感就看出来了.可以参考之前的题: https://www.cnblogs.com/hua-dong/p/9291507.html Christmas is coming! Eddy has received a Christmas tree as gift. Not surprisingly, the tree consists of N vertices and N-1 edges and magically remains connected. Cu…
题目链接 https://atcoder.jp/contests/agc014/tasks/agc014_e 题解 完了考场上树剖做法都没想到是不是可以退役了... 首先有一个巨难写的据说是\(O(n\log^3n)\)的树剖+树套树做法: 对于每条红边\((u,v)\), 给蓝树上两点间路径\(+1\), 然后每次选出一个值为\(1\)的边,找到覆盖它的红边然后把这条\(1\)的边断掉加上红边,再去掉红边的影响. 下面来说正解. 依然是上面的思路,然后发现假设断掉前\((i-1)\)条蓝边之后…