ACM
衍射
我看青山多妩媚,料青山看我应如是
展开
-
HDU-2473 Junk-Mail Filter(并查集的使用)
原题链接:https://vjudge.net/problem/11782/origin Description: Recognizing junk mails is a tough task. The method used here consists of two steps: 1) Extract the common characteristics from the incoming...原创 2018-08-12 10:53:39 · 208 阅读 · 0 评论 -
CodeForces - 722C Destroying Array (并查集/集合的插入和删除)
原题链接:https://vjudge.net/problem/511814/origin Description: You are given an array consisting ofnnon-negative integersa1, a2, ..., an. You are going to destroy integers in the array one by one. T...原创 2018-08-12 16:06:36 · 191 阅读 · 0 评论 -
CodeForces - 767C Garland
Once at New Year Dima had a dream in which he was presented a fairy garland. A garland is a set of lamps, some pairs of which are connected by wires. Dima remembered that each two lamps in the garland...原创 2018-08-16 16:05:55 · 206 阅读 · 0 评论 -
POJ - 1655 Balancing Act(树的重心)
Time limit:1000 ms;Memory limit:65536 kB Consider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the tree yields a forest: a collection of one or more trees. De...原创 2018-08-15 09:44:20 · 163 阅读 · 0 评论 -
UVALive - 3644 X-Plosives (并查集)
A secret service developed a new kind of explosive that attain its volatile property only when a specific association of products occurs. Each product is a mix of two different simple compounds, to wh...原创 2018-08-16 17:39:08 · 129 阅读 · 0 评论 -
HDU - 1520 Anniversary party (树的最大独立集)
Time limit :1000 ms ;Memory limit :32768 kB; OS :Windows There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of e...原创 2018-08-15 09:00:39 · 193 阅读 · 0 评论 -
UVA - 699 The Falling Leaves
给一棵二叉树,每个结点都有一个水平位置:左子结点在它左边1个单位,右子结点在右边1个单位。从左向右输出每个水平位置的所有结点的权值之和。如图6-7所示,从左到右的3个位置的权和分别为7,11,3。按照递归(先序) 方式输入,用-1表示空树。 样例输入: 5 7 -1 6 -1 -1 3 -1 -1 8 2 9 -1 -1 6 5 -1 -1 12 -1 -1 3 7 -1 -1 -1 -1...原创 2018-08-14 14:21:09 · 118 阅读 · 0 评论 -
UVa 839 Not so Mobile
输入一个树状天平,根据力矩相等原则判断是否平衡。如图6-5所示,所谓力矩相等,就是W l D l =W r D r ,其中W l 和W r 分别为左右两边砝码的重量,D为距离。 采用递归(先序)方式输入:先输入样例个数,空行,每个天平的格式为W l ,D l ,W r ,D r ,当W l 或W r 为0时,表示该“砝码”实际是一个子天平,接下来会描述这个子天平。当W l =W r =0时,会先描...原创 2018-08-14 10:40:26 · 125 阅读 · 0 评论 -
UVa 548 Tree(中序遍历+后序遍历)
给一棵点带权(权值各不相同,都是小于10000的正整数)的二叉树的中序和后序遍历,找一个叶子使得它到根的路径上的权和最小。如果有多解,该叶子本身的权应尽量小。输入中每两行表示一棵树,其中第一行为中序遍历,第二行为后序遍历。 样例输入: 3 2 1 4 5 7 6 3 1 2 5 6 7 4 7 8 11 3 5 16 12 18 8 3 11 7 16 18 12 5 255 255 样例输出...原创 2018-08-14 09:04:31 · 158 阅读 · 0 评论 -
UVa-679 Dropping Balls(二叉树的编号)
题目描述如下: 有一棵二叉树,最大深度为D,且所有叶子的深度都相同。所有结点从上到下从左到右 编号为1, 2, 3,…, 2D-1。在结点1处放一个小球,它会往下落。每个内结点上都有一个开关, 初始全部关闭,当每次有小球落到一个开关上时,状态都会改变。当小球到达一个内结点 时,如果该结点上的开关关闭,则往左走,否则往右走,直到走到叶子结点,如图6-2所 示: 一些小球从结点1处依次开始下落...原创 2018-08-13 18:28:32 · 183 阅读 · 0 评论