
高效算法
Joyyiwei
这个作者很懒,什么都没留下…
展开
-
UVA - 10895 Matrix Transpose
UVA - 10895Matrix TransposeTime Limit:3000MS Memory Limit:Unknown 64bit IO Format:%lld & %llu[Submit] [Go Back] [Status] Description A: Matrix Transp原创 2014-07-16 21:29:29 · 1098 阅读 · 0 评论 -
HDU - 4198 Quick out of the Harbour (BFS+优先队列)
DescriptionCaptain Clearbeard decided to go to the harbour for a few days so his crew could inspect and repair the ship. Now, a few days later, the pirates are getting landsick(Pirates get landsic原创 2014-07-15 16:05:20 · 1039 阅读 · 0 评论 -
HDU 4920 Matrix multiplication
Problem DescriptionGiven two matrices A and B of size n×n, find the product of them.bobo hates big integers. So you are only asked to find the result modulo 3. InputThe input consists of原创 2014-08-05 21:22:45 · 794 阅读 · 0 评论 -
CodeForces - 38E Let's Go Rolling!
DescriptionOn a number axis directed from the left rightwards, n marbles with coordinatesx1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is原创 2014-08-06 16:47:44 · 1349 阅读 · 0 评论 -
CodeForces - 61E Enemy is weak
DescriptionThe Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".Nevertheless原创 2014-08-07 11:09:27 · 1389 阅读 · 0 评论 -
HDU 4925 Apple Tree
Problem DescriptionI’ve bought an orchard and decide to plant some apple trees on it. The orchard seems like an N * M two-dimensional map. In each grid, I can either plant an apple tree to get one a原创 2014-08-07 17:45:10 · 1079 阅读 · 0 评论 -
HDU - 4970 Killing Monsters
Problem DescriptionKingdom Rush is a popular TD game, in which you should build some towers to protect your kingdom from monsters. And now another wave of monsters is coming and you need again to kn原创 2014-08-19 22:27:26 · 872 阅读 · 0 评论 -
hdu - 4965 Fast Matrix Calculation
Problem DescriptionOne day, Alice and Bob felt bored again, Bob knows Alice is a girl who loves math and is just learning something about matrix, so he decided to make a crazy problem for her.Bo原创 2014-08-19 23:06:21 · 696 阅读 · 0 评论 -
CodeForces 69D Dot (博弈+记忆化)
DescriptionAnton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up原创 2014-08-07 10:05:07 · 1728 阅读 · 0 评论 -
POJ - 2442 Sequence
DescriptionGiven m sequences, each contains n non-negative integer. Now we may select one number from each sequence to form a sequence with m integers. It's clear that we may get n ^ m this kind o原创 2014-08-08 14:22:45 · 960 阅读 · 0 评论 -
HDU 4923 Room and Moor
Problem DescriptionPM Room defines a sequence A = {A1, A2,..., AN}, each of which is either 0 or 1. In order to beat him, programmer Moor has to construct another sequence B = {B1, B2,... , BN} of原创 2014-08-07 20:25:34 · 950 阅读 · 0 评论 -
HDU - 2294 Pendant (DP滚动数组降维+矩阵快速幂)
DescriptionOn Saint Valentine's Day, Alex imagined to present a special pendant to his girl friend made by K kind of pearls. The pendant is actually a string of pearls, and its length is defined a原创 2014-07-30 16:40:35 · 1234 阅读 · 0 评论 -
HDU 4856 Tunnels
题意:求经过所有的管道的最短路程,管道内的时间不算思路:首先BFS处理出管道出口到其他管道入口的距离,然后在队友的指导下明白了状态转移#include #include #include #include #include using namespace std;const int MAXN = 16;const int INF = 0x3f3f3f3f;struct N原创 2014-07-08 19:43:34 · 1264 阅读 · 0 评论 -
UVA - 12232 Exclusive-OR (并查集扩展偏离向量)
DescriptionYou are not given n non-negative integersX0, X1,..., Xn-1 less than220, but they do exist, and their values never change.I'll gradually provide you some facts about them, and as原创 2014-07-17 19:24:23 · 1092 阅读 · 0 评论 -
UVA - 12130 Summits
DescriptionProblem G - SummitsTime limit: 8 secondsYou recently started working for the largest map drawing company in theNetherlands. Part of your job is to determine what the summits in apar原创 2014-07-18 15:37:46 · 1072 阅读 · 0 评论 -
UVA - 501 Black Box (优先队列或vector)
Description Black Box Our Black Box represents a primitive database. It can save an integer array and has a speciali variable. At the initial moment Black Box is empty and原创 2014-07-19 10:50:26 · 1248 阅读 · 0 评论 -
UVA - 586 Instant Complexity
Description Instant Complexity Analyzing the run-time complexity of algorithms is an important tool for designing efficient programs that solve a problem. An algorithm that r原创 2014-07-19 14:59:41 · 927 阅读 · 0 评论 -
UVA - 10537 The Toll! Revisited (最短路变形逆推)
DescriptionProblem G Toll! Revisited Input: Standard Input Output: Standard OutputTime Limit: 1 Second Sindbad the Sailor sold 66 silver spoons to the Sultan of Samarkand. The selling原创 2014-07-21 09:11:57 · 1747 阅读 · 0 评论 -
UVA - 11090 Going in Cycle!! (Bellman-Ford算法判负环)
DescriptionI IU P C2 0 06Problem G: Going in Cycle!!Input: standard input Output: standard output You are given a weighted directed gra原创 2014-07-21 10:35:20 · 1047 阅读 · 0 评论 -
UVA - 11374 Airport Express (Dijkstra模板+枚举)
DescriptionProblem D: Airport ExpressIn a small city called Iokh, a train service, Airport-Express, takes residents to the airport more quickly than other transports. There are原创 2014-07-20 10:33:28 · 965 阅读 · 0 评论 -
UVA - 769 Magic of David Copperfield
题意:著名的魔术师大卫科波菲尔喜欢表演下面的魔术:一个N行N列不同图片的矩阵出现在大屏幕上,我们给所有的图片这样命名: 每一个参与的观众被要求将手指放在左上方的图片上(即编号为1的图片),魔术师开始了:魔术师告诉观众在图片上移动k次(移动是把手指放到上下左右相邻的图片上,如果那儿有图片的话),然后他(魔术师)的手微微一指(指向一些图片)并说:“你不在这里”,然后……是真的!你的手指原创 2014-07-07 11:01:10 · 977 阅读 · 0 评论 -
UVA - 669 Defragment
题意:简单说就是将第i个簇号放回i,求最少的步数思路:只处理链形,和环形的情况,其他的可以不管,对于链形来说,只要倒置就行了,环形的找一个空闲的放一个,然后就是链形的情况了#include #include #include #include #include using namespace std;const int MAXN = 10005;int culsters[M原创 2014-07-06 20:35:04 · 905 阅读 · 0 评论 -
HDU - 3530 Subsequence
DescriptionThere is a sequence of integers. Your task is to find the longest subsequence that satisfies the following condition: the difference between the maximum element and the minimum element原创 2014-07-25 09:49:43 · 1440 阅读 · 0 评论 -
POJ - 1780 Code (欧拉回路+手写DFS)
DescriptionKEY Inc., the leading company in security hardware, has developed a new kind of safe. To unlock it, you don't need a key but you are required to enter the correct n-digit code on a keyp原创 2014-08-08 22:29:22 · 1205 阅读 · 0 评论 -
UVA - 10032 Tug of War (二进制标记+01背包)
DescriptionProblem F: Tug of WarA tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must be divided into two teams. Each person must be on one tea原创 2014-08-09 18:55:07 · 1710 阅读 · 0 评论 -
HDU - 4971 A simple brute force problem. (DP)
Problem DescriptionThere's a company with several projects to be done. Finish a project will get you profits. However, there are some technical problems for some specific projects. To solve the prob原创 2014-08-21 22:50:21 · 1120 阅读 · 0 评论 -
codeforces C#264. Gargari and Bishops
Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius.He has a n × n chessboard. Each cell of the chessboard has a number written on原创 2014-08-30 21:15:40 · 1004 阅读 · 0 评论 -
UVA - 1476 Error Curves (三分搜索)
Description Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a method called Linear Discriminant Analysis, which has many interesting properties.I原创 2014-09-02 16:32:08 · 1088 阅读 · 0 评论 -
Codeforces Round #266 (Div. 2) D. Increase Sequence
Peter has a sequence of integers a1, a2, ..., an. Peter wants all numbers in the sequence to equalh. He can perform the operation of "adding one on the segment[l, r]": add one to all elements of t原创 2014-09-16 13:19:51 · 1562 阅读 · 1 评论 -
Codeforces Round #266 (Div. 2) C. Number of Ways
You've got array a[1], a[2], ..., a[n], consisting ofn integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part原创 2014-09-16 10:51:42 · 1234 阅读 · 0 评论 -
Codeforces Round #265 (Div. 2) C. No to Palindromes!
Paul hates palindromes. He assumes that strings is tolerable if each its character is one of the firstp letters of the English alphabet and s doesn't contain any palindrome contiguous substring原创 2014-09-17 17:04:43 · 1353 阅读 · 1 评论 -
POJ - 3415 Common Substrings(后缀数组求长度不小于 k 的公共子串的个数+单调栈优化)
DescriptionA substring of a string T is defined as:T( i, k)= TiTi+1... Ti+k-1, 1≤ i≤ i+k-1≤| T|.Given two strings A, B and one integer K, we define S, a set of triples (i, j, k):S =原创 2014-09-29 11:22:39 · 1445 阅读 · 0 评论 -
HDU - 5009 Paint Pearls(dp+双向链表优化)
Problem DescriptionLee has a string of n pearls. In the beginning, all the pearls have no color. He plans to color the pearls to make it more fascinating. He drew his ideal pattern of the string o原创 2014-10-03 21:54:02 · 1841 阅读 · 0 评论 -
HDU Always Cook Mushroom (极角排序+树状数组)
Problem DescriptionMatt has a company, Always Cook Mushroom (ACM), which produces high-quality mushrooms. ACM has a large field to grow their mushrooms. The field can be considered as a 1000 *原创 2014-10-30 23:24:32 · 1060 阅读 · 0 评论 -
HDU - 5008 Boring String Problem (后缀数组+二分+RMQ)
Problem DescriptionIn this problem, you are given a string s and q queries.For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which原创 2014-10-03 14:36:19 · 1508 阅读 · 0 评论 -
HDU - 5036 Operation the Sequence
Problem DescriptionYou have an array consisting of n integers: a1=1,a2=2,a3=3,…,an=n. Then give you m operators, you should process all the operators in order. Each operator is one of four types原创 2014-10-12 21:24:32 · 1032 阅读 · 0 评论 -
UVA - 12316 Sewing Buttons with Grandma (有重复元素的组合)
Description Sewing Buttons with Grandma After so many years of studying math in the Academy of Colombian Mathematics (ACM) in the tropic, Eloi has finally decided to visit hi原创 2014-08-15 15:26:12 · 1109 阅读 · 2 评论 -
UVA - 12335 Lexicographic Order (第k大排列)
DescriptionA Lexicographic OrderInput: Standard Input Output: Standard Output The alphabet of a certain alien language consists of n distinct symbols. The原创 2014-08-14 11:48:21 · 2733 阅读 · 0 评论 -
UVA - 10588 Queuing at the doctors (队列)
DescriptionProblem H: Queuing at the doctors Due to the increasing number of weird viruses spreading around, all the members of the International Confederation of Revolver Enthusiasts (ICORE) ar原创 2014-09-06 20:22:03 · 1139 阅读 · 0 评论 -
UVA - 10043 Chainsaw Massacre
Description Problem E: Chainsaw Massacre Background As every year the Canadian Lumberjack Society has just held its annual woodcutting competition and the national forest原创 2014-08-09 15:52:22 · 1008 阅读 · 0 评论