![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
POJ
Kelisita
别再抱怨东西太难,只是自己不会,仅此而已
展开
-
POJ 3278 BFS题
大致题意:有n,k,在x轴上,然后农夫用三种 head-1, head+1 或 head*2 去走,问最少多少步可以将牛拉回来;PS:queue队列,要记好加入队列,出队,已经保存出队前一个元素; 要牢记需要剪枝;如果超出范围必须跳过,不然会RE;代码如下:#include #include #include using namespace std ;c原创 2016-01-23 23:18:48 · 389 阅读 · 0 评论 -
POJ 1287 Networking [prim求解最小生成树]
DescriptionYou are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may con原创 2016-07-26 13:49:20 · 302 阅读 · 0 评论 -
POJ 2421 Constructing Roads 【已知道路连通求最小生成树】
DescriptionThere are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, i原创 2016-07-26 14:16:49 · 304 阅读 · 0 评论 -
POJ 3246 Balanced Lineup 【RMQ求MAX-MIN的值】
DescriptionFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows原创 2016-07-27 14:18:25 · 270 阅读 · 0 评论 -
POJ 1330 Nearest Common Ancestors 【LCA·Tarjan离线算法】
A rooted tree is a well-known data structure in computer science and engineering. An example is shown below: In the figure, each node is labeled with an integer from {1, 2,...,16}. Node 8 is th原创 2016-07-28 15:37:26 · 328 阅读 · 0 评论 -
POJ 1251 Jungle Roads 【最小生成树】
DescriptionThe 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 ago. But the jungle overtakes r原创 2016-07-28 21:23:01 · 313 阅读 · 0 评论 -
POJ 1679 The Unique MST 【用次小生成树验证最小生成树是否唯一】
DescriptionGiven a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of原创 2016-07-29 15:20:25 · 362 阅读 · 0 评论 -
POJ 2349 Arctic Network 【最小生成树变形】
DescriptionThe Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the n原创 2016-07-29 17:38:51 · 310 阅读 · 0 评论 -
POJ 2031 Building a Space Station
DescriptionYou are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the原创 2016-07-29 20:36:23 · 175 阅读 · 0 评论 -
POJ 2377 Bad Cowtractors 【最大生成树】
DescriptionBessie has been hired to build a cheap internet network among Farmer John's N (2 <= N <= 1,000) barns that are conveniently numbered 1..N. FJ has already done some surveying, and found原创 2016-07-30 14:29:07 · 277 阅读 · 0 评论 -
POJ 2253 Frogger 【单源最短路】
DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full原创 2016-07-21 10:28:57 · 251 阅读 · 0 评论 -
POJ 1797 Heavy Transportation 【最短路思维+最大承载】
DescriptionBackground Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from原创 2016-07-21 10:38:45 · 409 阅读 · 0 评论 -
POJ 3268 Silver Cow Party [双向最短路求最大值]
DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirect原创 2016-07-21 11:34:29 · 259 阅读 · 0 评论 -
POJ 2406 Power Strings [KMP+循环节]
DescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponenti原创 2016-08-01 14:00:54 · 221 阅读 · 0 评论 -
POJ 2528 Mayor's posters[区间更新+查询+覆盖问题]
DescriptionThe 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 counci原创 2016-08-16 17:50:45 · 470 阅读 · 0 评论 -
POJ 2752 Seek the Name, Seek the Fame [前后缀相同的KMP]
DescriptionThe little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the sa原创 2016-08-01 16:44:18 · 274 阅读 · 0 评论 -
POJ 2236 Wireless Network
DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all c原创 2016-07-22 20:58:36 · 200 阅读 · 0 评论 -
POJ 3461&& hiho1015 Oulipo [KMP算法]
DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:Tout avait Pair nor原创 2016-05-31 16:07:55 · 349 阅读 · 0 评论 -
POJ 3624 【DP入门之01背包】
典型的01背包问题,很套路 唯一错的就是数组开太小RE了一次;上代码#include #include #include #include #include int n , m ;int w[50000],d[50000],dp[50000];using namespace std ;int main(){ while(cin>>n>>m) { for(int原创 2016-01-25 23:08:26 · 264 阅读 · 0 评论 -
POJ 3468 【动态区间改变区间值】
Description给出了一个序列,你需要处理如下两种询问。"C a b c"表示给[a, b]区间中的值全部增加c (-10000≤ c ≤ 10000)。"Q a b" 询问[a, b]区间中所有值的和。Input第一行包含两个整数N,Q。1≤ N,Q ≤ 100000.第二行包含n个整数,表示初始的序列A (-100000原创 2016-02-13 23:17:20 · 235 阅读 · 0 评论 -
POJ 2551 Dungeon Master
以后还是用容器写吧,手撸队列还是太麻烦了;一直找不到错在哪里了,后来才发现眼花啦,三个for循环把输出仍在里面了;就和线段树当时把预处理仍在里面一样,以后要仔细 仔细 仔细!大致题意:有一个3D的地牢,让你从S点到E点的最短时间,如果无法到达,就输出不可能; 广搜特性,搜出来的就是最短时间;Description原创 2016-02-15 01:12:25 · 253 阅读 · 0 评论 -
POJ 1797 最大负载【最短路】
注意:权值换为了最大负载量;所以是在d[v]与map[v][j]比最小值;DescriptionBackground Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tel原创 2016-03-16 21:30:01 · 377 阅读 · 0 评论 -
POJ 1321 棋盘问题
题面已知棋盘为N X N 的矩阵,也已知棋子数量K , 则问不在同一行,一列摆放棋子有多少种可能;PS:因为棋子数量有限,所以有可能会出现某一行并没有棋子的情况;故找到后只需要dfs下一行即可; 当k=sum,则代表这一次搜索以及结束,返回继续搜索;AC代码如下:#include using namespace std ;int n , k , vis[15],a原创 2016-01-23 00:39:23 · 322 阅读 · 0 评论 -
POJ 3984 记录路径的BFS
思路:从右下角往左上角开始搜索,然后搜到一个位置就把当前位置的上一个位置保存起来; 然后rear会一直增加,所以输出的时候, 就会从大到小输出,就做到了从左上到右下的输出;Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0,原创 2016-03-07 21:10:40 · 323 阅读 · 0 评论 -
POJ 2387 图论之最短路【三种写法】
最短路问题;坑点1:是先输入边,再输入点;坑点2:数据很大,不适合用别的模板;坑点3:有重边 需要判定;DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her原创 2016-03-13 00:05:28 · 4887 阅读 · 2 评论 -
【尺取法】poj 3061 Subsequence
DescriptionA sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal le原创 2016-04-13 12:49:42 · 378 阅读 · 0 评论 -
【尺取法】Jessica's Reading Problem
DescriptionJessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master原创 2016-04-13 15:15:09 · 247 阅读 · 0 评论 -
POJ 3641 快速幂+素数判断
DescriptionFermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide byp, the remainder is a. Some (but原创 2016-05-04 12:11:53 · 369 阅读 · 0 评论 -
POJ 1995 多项式求和取模
DescriptionPeople are different. Some secretly read magazines full of interesting girls' pictures, others create an A-bomb in their cellar, others like using Windows, and some like difficult mat原创 2016-05-04 12:36:35 · 535 阅读 · 0 评论 -
poj 3187 Backward Digit Sums
DescriptionFJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer原创 2016-04-20 11:38:25 · 250 阅读 · 0 评论 -
POJ 3050 Hopscotch
DescriptionThe cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows create a 5x5 rectilinear grid of digits paral原创 2016-04-21 16:04:39 · 259 阅读 · 0 评论 -
POJ 2406 Power Strings [KMP+循环节规律]
DescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponenti原创 2016-05-31 17:28:05 · 278 阅读 · 0 评论 -
POJ 1502 MPI Maelstrom 【单源最短路中求最大值】
DescriptionBIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKe原创 2016-07-21 23:05:26 · 282 阅读 · 0 评论