
POJ
邵光亮
要为自己喜欢的事情不留余力
展开
-
poj2823 Sliding Window(单调队列)
题意:给定一个长度为 NNN 的数字序列,要求你求出每个长度为 KKK 的区间内的最小值与最大值。单调队列做法:const int N = 1e6 + 10;const int mod = 998244353;int a[N], maxx[N], minn[N], queue1[N], queue2[N];//queue存位置int i, n, k, front1, front2, tail1, tail2, cnt;int main(){ sdd(n, k); cn..原创 2020-10-07 20:49:17 · 143455 阅读 · 0 评论 -
POJ3468 A Simple Problem with Integers(SplayTree做法)
DescriptionYou haveNintegers,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 t...原创 2019-10-21 19:36:26 · 182 阅读 · 0 评论 -
POJ3481 Double Queue(Treap)
DescriptionThe new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest, equipped with a modern computing environment provided by IBM Romania, and using modern informati...原创 2019-10-16 17:24:55 · 339 阅读 · 0 评论 -
POJ 3264 Balanced Lineup (RMQ求区间最值)
DescriptionFor the daily milking, Farmer John'sNcows (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. T...原创 2019-09-28 16:33:44 · 254 阅读 · 0 评论 -
POJ 1951 (模拟)
Description:A krunched word has no vowels ("A", "E", "I", "O", and "U") and no repeated letters. Removing vowels and letters that appear twice or more from MISSISSIPPI yields MSP. In a krunched word...原创 2019-06-12 23:30:02 · 694 阅读 · 0 评论 -
POJ 3660 Cow Contest.(Floyd)
Description:N(1 ≤N≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rat...原创 2019-06-16 23:25:37 · 624 阅读 · 0 评论 -
POJ2188
Description:The cows have erected clothes lines with N (1 <= N <= 1000) wires upon which they can dry their clothes after washing them. Having no opposable thumbs, they have thoroughly botched...原创 2019-06-01 17:59:03 · 682 阅读 · 0 评论 -
POJ 2189
Description:Farmer John has two feuding herds of cattle, the Moontagues and the Cowpulets. One of the bulls in the Moontague herd, Romeo, has fallen in love with Juliet, a Cowpulet. Romeo would like...原创 2019-06-01 18:02:02 · 701 阅读 · 0 评论 -
CodeForces 1110D Jongmah (思维dp)
传送门题意:给出n个不大于m的数字,如果三个数字连续或者相等,则可以组成三元组。求最多可以组成多少三元组。思路:dp[i][j][k]表示前i个人有j个(i-1,i,i+1),k个(i,i+1,i+2)时三元组有多少个。状态转移方程dp[i][k][l]=max(dp[i][k][l],dp[i-1][j][k]+l+(a[i]-j-k-l)/3);ac代码:#i...原创 2019-04-29 16:46:28 · 701 阅读 · 0 评论 -
POJ1190 生日蛋糕(dfs+剪枝)
生日蛋糕点击这里题意比较清晰,给定我们蛋糕的层数和体积,要我们去搭一个蛋糕,在保证每一层都比上面那一层的半径至少大1、高度至少大1的前提下,找到使得外表面积最小的一种方案。枚举的就是每一层的高度和半径,然后就是四个剪枝,第一个半径剪枝,第二个高度剪枝,第三个剩余体积大于等于剩余层蛋糕最小体积,第四个剪枝剩余体积小于等于剩余层蛋糕最大体积。代码如下:#include<ios...原创 2019-05-01 00:24:10 · 678 阅读 · 0 评论 -
POJ1426,Find The Multiple(DFS)
DescriptionGiven 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 may assume that n is not greater than ...原创 2019-04-16 23:42:58 · 555 阅读 · 0 评论 -
POJ 2531 Network Saboteur(DFS)
DescriptionA university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided the network into two subnetworks in order t...原创 2019-04-17 23:41:08 · 725 阅读 · 0 评论 -
POJ 3074 suduku(DFS)
DescriptionSudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3 as shown on the Figure. In some of the cells are written decimal digits from 1 t...原创 2019-04-18 23:38:15 · 805 阅读 · 0 评论 -
POJ 1321-棋盘问题(DFS)
Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= ...原创 2019-04-21 23:28:45 · 768 阅读 · 0 评论 -
POJ 2492 A Bug's Life(并查集)
DescriptionBackgroundProfessor 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 ...原创 2019-09-24 17:31:51 · 362 阅读 · 0 评论 -
POJ - 2528 Mayor's posters (离散化+线段树区间覆盖)
Description: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 counci...原创 2019-09-25 09:05:26 · 303 阅读 · 0 评论 -
POJ2774Long Long Message(后缀数组)
DescriptionThe little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being worried about spending so much on railway...原创 2019-10-06 18:53:25 · 370 阅读 · 0 评论 -
POJ1226 Substrings (后缀数组)
DescriptionYou are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given s...原创 2019-10-06 16:47:00 · 225 阅读 · 0 评论 -
POJ1785 Binary Search Heap Construction(Treap+RMQ)
DescriptionRead the statement of problem G for the definitions concerning trees. In the following we define the basic terminology of heaps. A heap is a tree whose internal nodes have each assigned ...原创 2019-10-05 17:54:42 · 192 阅读 · 0 评论 -
POJ2752 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 sam...原创 2019-10-05 15:59:20 · 174 阅读 · 0 评论 -
POJ 2185 Milking Grid (矩阵最小循环节KMP)
DescriptionEvery morning when they are milked, the Farmer John's cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 75) columns. As we all know, Farmer John ...原创 2019-10-05 11:11:06 · 287 阅读 · 0 评论 -
POJ3080 Blue Jeans (最长公共子序列 KMP)
DescriptionThe Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth wa...原创 2019-10-05 09:44:33 · 281 阅读 · 0 评论 -
POJ2406 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, exponentia...原创 2019-10-04 10:52:58 · 223 阅读 · 0 评论 -
POJ 1985 Cow Marathon (树的直径)
DescriptionAfter hearing about the epidemic of obesity in the USA, Farmer John wants his cows to get more exercise, so he has committed to create a bovine marathon for his cows to run. The marathon...原创 2019-09-29 18:01:58 · 159 阅读 · 0 评论 -
Poj 2452 Sticks Problem (RMQ+二分)
DescriptionXuanxuan has n sticks of different length. One day, she puts all her sticks in a line, represented by S1, S2, S3, ...Sn. After measuring the length of each stick Sk (1 <= k <= n), ...原创 2019-09-28 17:36:36 · 295 阅读 · 0 评论 -
POJ 1456 Supermarket (贪心or并查集)
DescriptionA 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 th...原创 2019-09-25 16:30:25 · 248 阅读 · 0 评论 -
POJ1129-Channel Allocation(DFS图的着色)
DescriptionWhen a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a strong signal. However, the channels used by each rep...原创 2019-04-22 23:13:23 · 741 阅读 · 0 评论 -
POJ1384 Piggy-Bank(完全背包)
DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea beh...原创 2019-03-30 09:15:28 · 688 阅读 · 0 评论 -
POJ2955 Brackets (区间DP)
DescriptionWe give the following inductive definition of a “regular brackets” sequence:the empty sequence is a regular brackets sequence, ifsis a regular brackets sequence, then (s) and [s] are...原创 2019-04-09 00:20:48 · 651 阅读 · 0 评论 -
POJ 2299 Ultra-QuickSort(树状数组+离散化 或 归并排序求逆序)
DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequen...原创 2019-08-28 16:37:37 · 613 阅读 · 0 评论 -
POJ 2631 Roads in the North(树的直径)
DescriptionBuilding and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such that there is only one route from a village to a v...原创 2019-08-27 16:52:29 · 599 阅读 · 0 评论 -
POJ 2253 Frogger(并查集+二分||Dijkstra)
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 of...原创 2019-08-27 10:09:42 · 552 阅读 · 0 评论 -
POJ 1456 Supermarket (贪心+并查集优化)
DescriptionA 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 th...原创 2019-08-27 09:32:25 · 654 阅读 · 0 评论 -
POJ 1733 Parity game (路径压缩并查集+离散化)
DescriptionNow and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subseque...原创 2019-08-26 17:20:48 · 690 阅读 · 0 评论 -
POJ 1182 食物链(并查集)
Description动物王国中有三类动物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个动物,用上述两种...原创 2019-08-26 15:18:01 · 657 阅读 · 0 评论 -
POJ 3468(树状数组+区间修改)
题目描述给定一个长度为N的数列A,以及M条指令,每条指令可能是以下两种之一:1、“C l r d”,表示把 A[l],A[l+1],…,A[r] 都加上 d。2、“Q l r”,表示询问 数列中第 l~r 个数的和。对于每个询问,输出一个整数表示答案。输入格式第一行两个整数N,M。第二行N个整数A[i]。接下来M行表示M条指令,每条指令的格式如题目描述所示。...原创 2019-08-12 21:31:43 · 734 阅读 · 0 评论 -
POJ 1741 Tree(点分治)
题目给你一棵TREE,以及这棵树上边的距离.问有多少对点它们两者间的距离小于等于K输入格式:N(n<=40000) 接下来n-1行边描述管道,按照题目中写的输入 接下来是k输出格式:一行,有多少对点之间的距离小于等于k输入输出样例输入样例#1:71 6 13 6 3 9 3 5 7 4 1 3 2 4 20 4 7 2 10输出样例#...原创 2019-08-15 17:14:30 · 544 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers (分块)
DescriptionYou haveNintegers,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...原创 2019-08-14 20:10:19 · 612 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers (线段树)
DescriptionYou haveNintegers,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...原创 2019-08-14 16:23:24 · 580 阅读 · 0 评论 -
POJ2676-Sudoku(dfs)
Description:Sudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3 as shown on the Figure. In some of the cells are written decimal digits from 1...原创 2019-08-05 17:06:48 · 649 阅读 · 0 评论