08 2017 档案

摘要:Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of 阅读全文
posted @ 2017-08-30 16:39 Zireael 阅读(196) 评论(0) 推荐(0)
摘要:Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stone 阅读全文
posted @ 2017-08-28 20:40 Zireael 阅读(214) 评论(0) 推荐(0)
摘要:FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line 阅读全文
posted @ 2017-08-28 19:35 Zireael 阅读(237) 评论(0) 推荐(0)
摘要:Description 可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。  阅读全文
posted @ 2017-08-26 13:43 Zireael 阅读(180) 评论(0) 推荐(0)
摘要:题意: 在平面上有n个点,要让所有n个点都连通,所以你要构造一些边来连通他们,连通的费用等于两个端点的欧几里得距离的平方。另外还可以选择q个套餐,可以购买,套餐内的所有点将会被连通。求最小花费。 题解: 如果不选择套餐的话,就是裸的MST。现在有了套餐可以选择,可以选择多个,那么就把它们(套餐里的点 阅读全文
posted @ 2017-08-22 14:24 Zireael 阅读(159) 评论(0) 推荐(0)
摘要:题意: 有多个供电站和村庄,问最少需要多少花费可以使所有村庄通上电。 题解: 刚开始不知道该怎么做,后来想了想,直接把供电站先加入到最小生成树里,(供电站之间的边权值为0)。很简单,裸题。 阅读全文
posted @ 2017-08-21 16:58 Zireael 阅读(241) 评论(0) 推荐(0)
摘要:题意: 求图中的最小生成树和次小生成树。 题解: 一种容易想到的方法是枚举删除最小生成树上的边,再求最小生成树。用kruskal这种算法的复杂度为O(n*elog2e),当图比较稠密时,复杂度接近O(n^3)。 但有一种更简单的方法:先求最小生成树T,枚举添加不在T中的边,则添加后一定会形成环。找到 阅读全文
posted @ 2017-08-20 17:00 Zireael 阅读(345) 评论(0) 推荐(0)
摘要:Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication te 阅读全文
posted @ 2017-08-20 14:06 Zireael 阅读(231) 评论(0) 推荐(0)
摘要:Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G is an ordered pair (V, E), where V is a 阅读全文
posted @ 2017-08-19 11:18 Zireael 阅读(341) 评论(0) 推荐(0)
摘要:Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The com 阅读全文
posted @ 2017-08-18 15:58 Zireael 阅读(250) 评论(0) 推荐(0)
摘要:Description Given a connected undirected graph, tell if its minimum spanning tree is unique.Definition 1 (Spanning Tree): Consider a connected, undire 阅读全文
posted @ 2017-08-17 15:38 Zireael 阅读(227) 评论(0) 推荐(0)
摘要:The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ag 阅读全文
posted @ 2017-08-16 15:51 Zireael 阅读(193) 评论(0) 推荐(0)
摘要:Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs you 阅读全文
posted @ 2017-08-16 14:26 Zireael 阅读(201) 评论(0) 推荐(0)
摘要:省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。 Input测试输入包含若干测试用例。每个 阅读全文
posted @ 2017-08-16 11:22 Zireael 阅读(201) 评论(0) 推荐(0)
摘要:相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件, 阅读全文
posted @ 2017-08-16 10:02 Zireael 阅读(200) 评论(0) 推荐(0)
摘要:省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 Input测试输入包含若干测试用例。每个测试用例的第1行给出评 阅读全文
posted @ 2017-08-15 14:42 Zireael 阅读(162) 评论(0) 推荐(0)
摘要:You are given three n × n matrices A, B and C. Does the equation A × B = C hold true? You are given three n × n matrices A, B and C. Does the equation 阅读全文
posted @ 2017-08-14 16:53 Zireael 阅读(228) 评论(0) 推荐(0)
摘要:Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to pl 阅读全文
posted @ 2017-08-14 12:05 Zireael 阅读(1024) 评论(0) 推荐(0)
摘要:http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=682&pid=1003 中文题意,不再描述。 题解: 顺序给山峰出现的时间,明显地用二分来查找。然后连通块用并查集(也可以BFS,复杂度都是O(n))来维护。 1 阅读全文
posted @ 2017-08-11 10:23 Zireael 阅读(228) 评论(0) 推荐(0)
摘要:此文为转,作者已不可考据 初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj3295) (6)模拟法.(poj1068,poj2632,poj1573,poj 阅读全文
posted @ 2017-08-11 09:27 Zireael 阅读(358) 评论(0) 推荐(0)
摘要:You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. 阅读全文
posted @ 2017-08-10 14:32 Zireael 阅读(187) 评论(0) 推荐(0)
摘要:There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no 阅读全文
posted @ 2017-08-10 10:52 Zireael 阅读(223) 评论(0) 推荐(0)
摘要:Now an emergent task for you is to open a password lock. The password is consisted of four digits. Each digit is numbered from 1 to 9. Each time, you 阅读全文
posted @ 2017-08-10 09:59 Zireael 阅读(219) 评论(0) 推荐(0)
摘要:The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could f 阅读全文
posted @ 2017-08-09 16:40 Zireael 阅读(221) 评论(0) 推荐(0)
摘要:Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You m 阅读全文
posted @ 2017-08-09 10:35 Zireael 阅读(254) 评论(0) 推荐(0)
摘要:The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room 阅读全文
posted @ 2017-08-08 17:02 Zireael 阅读(200) 评论(0) 推荐(0)
摘要:Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a numb 阅读全文
posted @ 2017-08-08 15:12 Zireael 阅读(181) 评论(0) 推荐(0)
摘要:题意: 给出油田的数量,八连通的“@”认为是一个油田。和POJ 2386 Lake Counting这个题几乎一样。 直接上代码: 阅读全文
posted @ 2017-08-08 11:09 Zireael 阅读(200) 评论(0) 推荐(0)
摘要:A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacen 阅读全文
posted @ 2017-08-08 10:27 Zireael 阅读(175) 评论(0) 推荐(0)
摘要:/*大数加法*/ # include # include # include void add(char* a,char* b,char* c) { int i,j,k,max,min,n,temp; char *s,*pmax,*pmin; max=strlen(a); min=strlen(b); if (max=0;i--,j--,k--) ... 阅读全文
posted @ 2017-08-08 09:26 Zireael 阅读(279) 评论(0) 推荐(0)
摘要:在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若 阅读全文
posted @ 2017-08-07 16:36 Zireael 阅读(240) 评论(0) 推荐(0)
摘要:Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and 阅读全文
posted @ 2017-08-07 15:11 Zireael 阅读(214) 评论(0) 推荐(0)
摘要:Exponential notation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a pos 阅读全文
posted @ 2017-08-06 17:22 Zireael 阅读(279) 评论(0) 推荐(0)
摘要:有N个岛连在一起形成了一个大的岛屿,如果海平面上升超过某些岛的高度时,则这个岛会被淹没。原本的大岛屿则会分为多个小岛屿,如果海平面一直上升,则所有岛都会被淹没在水下。 给出N个岛的高度。然后有Q个查询,每个查询给出一个海平面的高度H,问当海平面高度达到H时,海上共有多少个岛屿。例如: 岛屿的高度为: 阅读全文
posted @ 2017-08-04 13:09 Zireael 阅读(477) 评论(0) 推荐(0)
摘要://FFT 大整数乘法 #include #include #include #include using namespace std; const int N = 500005; const double pi = acos(-1.0); char s1[N],s2[N]; int len,res[N]; struct Complex { double r,i; Co... 阅读全文
posted @ 2017-08-04 10:06 Zireael 阅读(555) 评论(0) 推荐(1)
摘要:动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说 阅读全文
posted @ 2017-08-02 15:41 Zireael 阅读(326) 评论(0) 推荐(0)
摘要:给n组操作,每组操作形式为x y p。 当p为1时,如果第x变量和第y个变量可以相等,则输出YES,并限制他们相等;否则输出NO,并忽略此次操作。 当p为0时,如果第x变量和第y个变量可以不相等,则输出YES,并限制他们不相等 ;否则输出NO,并忽略此次操作。 Input输入一个数n表示操作的次数( 阅读全文
posted @ 2017-08-02 15:24 Zireael 阅读(272) 评论(0) 推荐(0)
摘要:有n个点,一开始都是孤立的,然后有I,E两种操作 I u v,把u的父节点设为v,距离为abs(u-v) % 1000,保证u之前没有父节点 E 询问u到根节点的距离 阅读全文
posted @ 2017-08-02 15:17 Zireael 阅读(203) 评论(0) 推荐(0)