![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法刷题
文章平均质量分 86
算法刷题
旺旺_碎_冰冰
这个作者很懒,什么都没留下…
展开
-
数螃蟹(思路题)
B. 数螃蟹 Time limit per test: 2.0 seconds Memory limit: 512 megabytes kblack 在做数螃蟹的实验。按照「螃蟹爷爷的秘诀」一书上介绍的:由于东方神秘力量的影响,螃蟹的个数是一个完美的等差数列,例如:−2,−1,0,1,2,…。是的,kblac...原创 2018-05-14 17:03:50 · 2292 阅读 · 0 评论 -
PAT 1003 Emergency(最短路(迪杰斯特拉||贝尔曼)最小边权下的最大点权)
1003. Emergency (25)时间限制 400 ms内存限制 65536 kB代码长度限制 16000 B判题程序 Standard 作者 CHEN, YueAs an emergency rescue team leader of a city, you are given原创 2018-01-15 23:17:38 · 423 阅读 · 0 评论 -
PAT 1090 1079 (树的遍历)
1090. Highest Price in Supply Chain (25)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Sta原创 2018-02-05 23:40:55 · 172 阅读 · 0 评论 -
PAT 1020(由二叉树的中序和后序,求层序遍历) 1086(由二叉树的中序和先序求后序遍历)
1020. Tree Traversals (25)时间限制 400 ms内存限制 65536 kB代码长度限制 16000 B判题程序 Standard 作者 CHEN, YueSuppose that all the keys in a binary tree are distinct po原创 2018-02-04 22:40:03 · 228 阅读 · 0 评论 -
PAT 1043 Is It a Binary Search Tree(二叉查找树)
1043. Is It a Binary Search Tree (25)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with k原创 2018-02-03 22:31:01 · 235 阅读 · 0 评论 -
2018年全国多校算法寒假训练营练习比赛(第五场)A:逆序数(小技巧)
链接:https://www.nowcoder.com/acm/contest/77/A来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld题目描述在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个...原创 2018-02-27 17:46:52 · 360 阅读 · 0 评论 -
最小化价格(STL&二分)
链接:https://www.nowcoder.com/acm/contest/112/A来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld题目描述现有n组人,m个地点,给出每组人的人数,每个地点可容纳的最大人数和选择的价格 要求一种方式,使得每组人都到一个各不相同的地点,最小化选择的价格 ...原创 2018-05-14 20:22:31 · 195 阅读 · 0 评论 -
Maximum of Maximums of Minimums codeforces 872 B(简单思路)
题意:给你一个数组,长度为n,要你把数组分为k组,注意每一组都必须要是连续的,从每段里面取最小值,然后从k个最小值里面找出最大值就是答案。#include<stdio.h>#include<algorithm>using namespace std;const int N=1e5+5;int a[N],maxa,mina;int main(){ i...原创 2018-08-15 09:55:40 · 317 阅读 · 0 评论 -
codeforce 847B Preparing for Merge Sort(二分)
题目链接:点击打开链接B. Preparing for Merge Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIvan has an array consisting of n different integers. He dec...原创 2017-12-05 16:27:39 · 244 阅读 · 0 评论 -
Vasiliy's Multiset CodeForces - 706D(异或&01字典树)
Author has gone out of the stories about Vasiliy, so here is just a formal task description.You are given q queries and a multiset A, initially containing only integer 0. There are three types of quer...原创 2018-05-11 19:13:08 · 172 阅读 · 0 评论 -
CodeForces - 907B Tic-Tac-Toe(模拟题)
B. Tic-Tac-Toetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo bears are playing tic-tac-toe via mail. It's borin原创 2018-04-02 18:01:06 · 339 阅读 · 0 评论 -
CodeForces - 451C(模拟)
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assu...原创 2018-03-29 23:12:57 · 396 阅读 · 0 评论 -
cf(950B)Intercepted Message(简单模拟)
B. Intercepted Messagetime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputHacker Zhorik wants to decipher two secret mess原创 2018-03-14 12:32:56 · 296 阅读 · 0 评论 -
CodeForces - 940B(模拟)
Right now she actually isn't. But she will be, if you don't solve this problem.You are given integers n, k, A and B. There is a number x, which is initially equal ton. You are allowed to perfo原创 2018-03-27 17:30:35 · 329 阅读 · 0 评论 -
CodeForces - 940C(模拟)
And where the are the phone numbers?You are given a string s consisting of lowercase English letters and an integerk. Find the lexicographically smallest stringt of length k, such that its set o原创 2018-03-27 17:11:14 · 570 阅读 · 0 评论 -
CodeForces - 937B(素数打表)
The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from2 to y. S原创 2018-03-28 10:49:30 · 239 阅读 · 0 评论 -
CodeForces - 922B (异或)
Imp is in a magic forest, where xorangles grow (wut?)A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceedingn, and the xor-sum of the leng原创 2018-03-28 11:50:04 · 317 阅读 · 0 评论 -
Sausage Maximization CodeForces - 282E(异或&01字典树)
The Bitlandians are quite weird people. They have their own problems and their own solutions. They have their own thoughts and their own beliefs, they have their own values and their own merits. They ...原创 2018-05-11 17:49:19 · 250 阅读 · 0 评论 -
Predict Outcome of the Game CodeForces - 451C (分情况讨论)
There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played.You are an avid football fan, but recently you missed the whole k games. Fort...原创 2018-03-30 02:17:05 · 277 阅读 · 0 评论 -
POJ 3087 Shuffle'm Up (简单模拟)
给定两个长度为len的字符串s1和s2, 接着给出一个长度为len*2的字符串s12。将字符串s1和s2通过一定的变换变成s12,找到变换次数变换规则如下:假设s1=12345,s2=67890变换后的序列 s=6172839405如果s和s12完全相等那么输出变换次数如果不完全相等,s的前半部分作为s1,后半部分作为s2,重复上述过程。 Inp原创 2018-03-13 18:47:44 · 226 阅读 · 0 评论 -
POJ 1511 Invitation Cards(优先队列优化后的迪杰斯特拉)
In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They原创 2018-01-19 13:48:11 · 308 阅读 · 0 评论 -
Web Navigation POJ - 1028(简单的栈应用)
Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be re原创 2018-05-08 21:04:04 · 326 阅读 · 1 评论 -
Ultra-QuickSort POJ - 2299 (树状数组求逆序数&离散化简单)
In 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 sequence is sorted i...原创 2018-08-04 18:36:02 · 172 阅读 · 0 评论 -
POJ 3984 迷宫问题(输出路线)
定义一个二维数组: 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表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 Input 一个5 × 5的二维数组,...原创 2017-12-15 15:29:52 · 214 阅读 · 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 r原创 2018-01-11 21:37:56 · 260 阅读 · 0 评论 -
Scrambled Polygon POJ - 2007 (极角排序)
A closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the vertices of the polygon. When one starts at any vertex of a clo原创 2018-04-11 12:04:00 · 225 阅读 · 0 评论 -
两道差分约束(最短路)POJ 3159 Candies POJ 3196 Layout
During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the原创 2018-01-21 10:27:44 · 293 阅读 · 1 评论 -
Blue Jeans poj 3080(暴力&kmp)
The 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 was...原创 2018-05-30 19:32:41 · 246 阅读 · 0 评论 -
POJ 2263 Frogger(最大值的最小值) POJ 1797 Heavy Transportation (最小值的最大值)
Freddy 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 tourists' sun原创 2018-01-07 15:44:58 · 220 阅读 · 0 评论 -
POJ 3660 Cow Contest(最短路弗洛伊德预处理或者迪杰斯克拉)
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 rating that is原创 2018-01-13 13:22:34 · 278 阅读 · 0 评论 -
Conscription POJ - 3723(最小生成树)
Windy has a country, and he wants to build an army to protect his country. He has picked upN girls and M boys and wants to collect them to be his soldiers. To collect a soldier without any privilege原创 2018-04-07 20:13:59 · 184 阅读 · 0 评论 -
Ping pong (树状数组)
N(3<=N<=20000) ping pong players live along a west-east street(consider the street as a line segment).Each player has a unique skill rank. To improve their skill rank, they often compete with e...原创 2018-08-04 18:43:29 · 1170 阅读 · 0 评论 -
Stars (树状数组)
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and ...原创 2018-08-02 11:38:10 · 538 阅读 · 1 评论 -
NYOJ 860 又见01背包(01背包)
又见01背包时间限制:1000 ms | 内存限制:65535 KB难度:3描述 有n个重量和价值分别为wi 和 vi 的 物品,从这些物品中选择总重量不超过 W 的物品,求所有挑选方案中物品价值总和的最大值。 1 1 1 1 输入多组测试数据。每组测试数据第一行输入,n 和 W ,接下来有n行,每行输入两个数,代表第i个物原创 2018-03-07 17:29:11 · 204 阅读 · 0 评论 -
完全背包
NYOJ 311 完全背包完全背包时间限制:3500 ms | 内存限制:65535 KB难度:4描述 直接说题意,完全背包定义有N种物品和一个容量为V的背包,每种物品都有无限件可用。第i种物品的体积是c,价值是w。求解将哪些物品装入背包可使这些物品的体积总和不超过背包容量,且价值总和最大。本题要求是背包恰好装满背包时,求出最大价值总和是多少。如果不能恰好装满背原创 2018-03-07 19:54:49 · 218 阅读 · 0 评论 -
Nightmare(bfs)
Nightmare时间限制:1000 ms | 内存限制:65535 KB难度:4输入The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.Ea...原创 2018-07-17 17:56:47 · 297 阅读 · 0 评论 -
blockhouses(dfs)
blockhouses时间限制:1000 ms | 内存限制:65535 KB难度:3输入The input file contains one or more map descriptions, followed by a line containing the number 0 that signals the end of the file. Each map descr...原创 2018-07-18 18:37:49 · 285 阅读 · 0 评论 -
吝啬的国度 NYOJ 20(深搜&广搜)
吝啬的国度 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 在一个吝啬的国度里有N个城市,这N个城市间只有N-1条路把这个N个城市连接起来。现在,Tom在第S号城市,他有张该国地图,他想知道如果自己要去参观第T号城市,必须经过的前一个城市是几号城市(假设你不走重复的路)。输入第一行输入...原创 2018-05-29 21:04:34 · 216 阅读 · 0 评论 -
三个水杯 NYOJ 21(广搜)
三个水杯 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子。三个水杯之间相互倒水,并且水杯没有标识,只能根据给出的水杯体积来计算。现在要求你写出一个程序,使其输出使初始状态到达目标状态的最少次数。 输入第一行一个整...原创 2018-05-29 21:08:06 · 565 阅读 · 0 评论 -
坦克大战 nyoj 284(优先队列+广搜)
坦克大战 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on com...原创 2018-05-30 11:07:54 · 260 阅读 · 0 评论