![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
poj
萧瑟1
这个作者很懒,什么都没留下…
展开
-
最长上升子序列的两种求法 POJ 2533
最长上升子序列一共有两种求法:1.dp,也可以说的纯暴力吧。dp[i]表示以a[i]为结尾的最长上升子序列的长度。所以只要满足j<i且a[j]<a[i],则一定满足dp[j]=max(dp[j],dp[i]+1);复杂度为n^2;2.是在上述方法的优化,建一个dp数组。dp[i]表示长度为i的上升子序列中末尾元素的最小值。因为dp数组一定是有序的,这样每次插...原创 2019-03-23 10:01:30 · 410 阅读 · 0 评论 -
POJ 1458 Common Subsequence
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a ...原创 2018-11-05 17:58:56 · 140 阅读 · 0 评论 -
poj 2891 Strange Way to Express Integers 中国剩余定理模板
Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following: Choose k different positive intege...原创 2018-10-17 13:11:39 · 116 阅读 · 0 评论 -
POJ 1061 青蛙的约会 扩展欧几里得
Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。...原创 2018-10-10 21:02:29 · 128 阅读 · 0 评论 -
Poj 1006 Biorhythms 中国剩余定理
DescriptionSome people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they ...原创 2018-10-16 16:03:18 · 181 阅读 · 0 评论 -
POJ - 3320 C - Jessica's Reading Problem 尺取法+map
Jessica'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 all ideas incl...原创 2018-10-13 16:30:07 · 130 阅读 · 0 评论 -
Poj 3061 Subsequence 尺取法
A 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 length o...原创 2018-10-13 13:59:22 · 123 阅读 · 0 评论 -
Poj 3641 Pseudoprime numbers 快速幂取模
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 by p, the remainder is a. Some (but no...原创 2018-10-11 21:10:18 · 153 阅读 · 0 评论 -
Poj 1995 Raising Modulo Numbers 快速幂取模
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 mathema...原创 2018-10-11 20:36:55 · 106 阅读 · 0 评论 -
Poj 2142 The Balance 扩展欧几里得
DescriptionMs. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can ...原创 2018-10-11 14:01:10 · 141 阅读 · 0 评论 -
Poj 2115 C Looooops 扩展欧几里得
DescriptionA Compiler Mystery: We are given a C-language style for loop of typefor (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to va...原创 2018-10-11 09:08:24 · 128 阅读 · 0 评论 -
POJ 2395 Out of Hay 最小生成树
The cows have run out of hay, a horrible event that must be remedied immediately. Bessie intends to visit the other farms to survey their hay situation. There are N (2 <= N <= 2,000) farms (numb...原创 2018-08-21 23:21:06 · 130 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers 区间更新模板题
You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the ...原创 2018-08-17 20:29:20 · 116 阅读 · 0 评论 -
POJ 1088 滑雪 (搜索)
DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 ...原创 2018-11-05 21:28:39 · 134 阅读 · 0 评论 -
POJ 1050 To the Max(动态规划)
Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of...原创 2018-11-08 09:38:27 · 383 阅读 · 2 评论 -
POJ 1083 Moving Tables 贪心
DescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side...原创 2018-11-08 21:22:40 · 154 阅读 · 0 评论 -
POJ - 3264 Balanced Lineup 线段树
题目:For 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. To keep th...原创 2019-03-16 15:55:35 · 135 阅读 · 0 评论 -
POJ - 2528 Mayor's posters 线段树+特殊离散化+区间更新
题目: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 fina...原创 2019-03-16 10:26:24 · 149 阅读 · 0 评论 -
poj 3189 Steady Cow Assignment 二分图多重匹配+二分
题目:Farmer John's N (1 <= N <= 1000) cows each reside in one of B (1 <= B <= 20) barns which, of course, have limited capacity. Some cows really like their current barn, and some are not ...原创 2019-03-10 20:11:50 · 144 阅读 · 0 评论 -
poj 2112 Optimal Milking 二分图多重匹配+floyd+二分
题目:FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths runs among the cows and the milking ma...原创 2019-03-10 17:12:22 · 148 阅读 · 0 评论 -
Uva 1151 Buy or Build 二进制枚举+最小生成树
题目描述万维网(WWN)是一家运营大型电信网络的领先公司。 WWN希望在Borduria建立一个新的网络,您需要帮助WWN确定如何以最低的总成本设置其网络。有几个本地公司运营着一些小型网络(以下称为子网),部分覆盖了Borduria的n个最大城市。 WWN希望建立一个连接所有n个城市的网络。 要实现这一目标,它可以从头开始在城市之间建设网络,也可以从本地公司购买一个或多个子网。 您需要帮助WW...原创 2019-03-14 14:19:15 · 170 阅读 · 0 评论 -
poj 2594 Treasure Exploration 匈牙利算法+floyd缩点
题目:Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences, you would never...原创 2019-03-09 16:40:09 · 127 阅读 · 0 评论 -
poj 1422 Air Raid 匈牙利算法
题目:Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets yo...原创 2019-03-09 11:53:26 · 118 阅读 · 0 评论 -
poj 1463 Strategic Game 匈牙利算法
题目:Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a me...原创 2019-03-09 10:18:23 · 115 阅读 · 0 评论 -
poj 3020 Antenna Placement 匈牙利算法
题目:The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discovery of ...原创 2019-03-09 09:31:43 · 155 阅读 · 0 评论 -
POJ - 3984 迷宫问题 记忆化搜索
Description定义一个二维数组:int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。...原创 2019-02-14 11:11:04 · 381 阅读 · 0 评论 -
POJ - 3279 Fliptile
代码如下:#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <queue>using namespace std;const int maxn=20;const int INF=0x3f3f3f3f;i...原创 2019-02-13 16:43:58 · 135 阅读 · 0 评论 -
POJ - 1321 棋盘问题
思路:以每一行进行搜索,符合条件就进行相应操作。代码如下:#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>using namespace std;typedef long long ll;const int maxn=10;...原创 2019-02-13 12:24:22 · 107 阅读 · 0 评论 -
POJ 1716 Intervals 差分约束
You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.Write a program that:reads the number of intervals, their end points and integers c1, ..., cn from the standard input,c...原创 2018-08-22 12:11:37 · 169 阅读 · 0 评论 -
POJ 3169 Layout 差分约束+spfa
DescriptionLike everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. T...原创 2018-08-22 11:30:26 · 180 阅读 · 0 评论 -
POJ 1456 Supermarket
A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starting from the moment the s...原创 2018-08-09 00:12:45 · 115 阅读 · 0 评论 -
POJ 1724 ROADS
N cities named with numbers 1 ... N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll that needs to be paid for the road (expressed in th...原创 2018-08-02 10:13:54 · 108 阅读 · 0 评论 -
POJ 3069 Saruman's Army 贪心
DescriptionSaruman 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 stones, known as palantirs, among the troo...原创 2018-08-10 15:06:10 · 108 阅读 · 0 评论 -
POJ 3617 Best Cow Line 贪心
DescriptionFJ 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 and herds them past the judges.The...原创 2018-08-10 14:19:02 · 114 阅读 · 0 评论 -
POJ 1182 食物链 并查集变式
动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话...原创 2018-08-10 11:45:21 · 112 阅读 · 0 评论 -
POJ 2494 A Bug's Life 并查集变形
BackgroundProfessor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gende...原创 2018-08-10 00:31:56 · 174 阅读 · 0 评论 -
POJ 3259 Wormholes Bellman-Ford最短路径算法
While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that i...原创 2018-08-05 23:07:45 · 224 阅读 · 0 评论 -
POJ 3268 Silver Cow Party
One 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) unidirectional (one-way ro...原创 2018-08-05 10:37:31 · 128 阅读 · 0 评论 -
POJ 1984 Navigation Nightmare
Farmer John's pastoral neighborhood has N farms (2 <= N <= 40,000), usually numbered/labeled 1..N. A series of M (1 <= M < 40,000) vertical and horizontal roads each of varying lengths (1 ...原创 2018-08-09 13:43:24 · 171 阅读 · 0 评论 -
poj 1611 The Suspects 并查集
The SuspectsTime Limit: 1000MS Memory Limit: 20000K Total Submissions: 49056 Accepted: 23475 DescriptionSevere acute respiratory syndrome (SARS), an atypical pneumonia of unkno...原创 2018-07-31 15:25:34 · 147 阅读 · 0 评论