摘要: dzy 手上有一张n 个点m 条边的联通无向图,仙人掌是一张每条边最多在一个简单环内的联通无向图。他想求这个无向图的生成仙人掌中最多有多少条边。 但是dzy 觉得这个问题太简单了,于是他定义了“美丽的生成仙人掌”,即在一个生成仙人掌中如果满足对于任意编号为i,j (i < j) 的两点,存在一条它们之间的简单路径上面有j-i+1 个点,则这个仙人掌是美丽的。 他现在想要知道这张图的美丽的生成仙人掌中最多有多少条边,你能帮帮他吗? 阅读全文
posted @ 2016-10-30 15:36 ZegWe 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 给定一棵树,每个节点有一个值。对于一条路径,它的值为路径上所有点的值的乘积。求出树上所有路径的值的和。 注意:单个点也算一条路径。 阅读全文
posted @ 2016-10-30 15:11 ZegWe 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 给你一张图,图上有 n 个点,m 条边,要你找到两个点,使其最短路恰好包含给定的 k 个点。输出这条最短路的长度,输入保证有解。 阅读全文
posted @ 2016-10-26 22:02 ZegWe 阅读(187) 评论(0) 推荐(0) 编辑
摘要: Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a consecutive subsequence of the original sequence. Every part must satisfy that the sum of the integers in the part is not greater than a given integer M. You are to find a cutting that minimizes the su 阅读全文
posted @ 2016-10-25 22:03 ZegWe 阅读(915) 评论(0) 推荐(1) 编辑
摘要: These days, Sempr is crazed on one problem named Crazy Thair. Given N (1 ≤ N ≤ 50000) numbers, which are no more than 109, Crazy Thair is a group of 5 numbers {i, j, k, l, m} satisfying: 1. 1 ≤ i < j < k < l < m ≤ N 2. Ai < Aj < A 阅读全文
posted @ 2016-10-24 18:29 ZegWe 阅读(221) 评论(0) 推荐(0) 编辑
摘要: Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem. There is a very long board with length L centimeter, L is a positive integer, so we can evenly divide the board into L segments, and they are labeled by 1, 2, ... L from left to right, each is 1 c 阅读全文
posted @ 2016-10-23 20:18 ZegWe 阅读(405) 评论(0) 推荐(0) 编辑
摘要: Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New Year was approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had to travel by train to Mianyang, Sichuan Province for the winter camp selection of the national team of Olympiad in Informatics. It was one o’clock a.m. and dark out 阅读全文
posted @ 2016-10-23 16:26 ZegWe 阅读(455) 评论(0) 推荐(0) 编辑
摘要: 对于一个排列,考虑相邻的两个元素,如果后面一个比前面一个大,表示这个位置是上升的,用 I 表示,反之这个位置是下降的,用 D表示。如排列 3,1,2,7,4,6,5 可以表示为 DIIDID。 现在给出一个长度为 n-1的排列表示,问有多少种 1 到n 的排列满足这种表示。 阅读全文
posted @ 2016-10-22 11:16 ZegWe 阅读(602) 评论(3) 推荐(2) 编辑
摘要: The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the posters and introduce the following rules: Every candidate can place exactly one poster on the wall. All posters are of the 阅读全文
posted @ 2016-10-21 18:05 ZegWe 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 给定一个长度为 N 颜色序列A,有M个询问:每次询问一个区间里是否有一种颜色的数量超过了区间的一半,并指出是哪种颜色。 阅读全文
posted @ 2016-10-17 09:58 ZegWe 阅读(614) 评论(0) 推荐(0) 编辑