ACM算法
文章平均质量分 80
丶先森
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #465 (Div. 2) C. Fifa and Fafa(圆问题,数论)
C. Fifa and Fafatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFifa and Fafa are sharing a flat. Fifa loves video games and wants to download a ne...原创 2018-02-20 16:16:48 · 593 阅读 · 0 评论 -
POJ3614Sunscreen(优先队列+贪心)
SunscreenTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8435 Accepted: 2981DescriptionTo avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 25原创 2017-04-14 21:18:07 · 961 阅读 · 0 评论 -
POJ2395Out of Hay(最小生成树Kruskal模板)
Out of HayTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 16495 Accepted: 6460DescriptionThe cows have run out of hay, a horrible event that must be rem原创 2017-04-14 21:06:12 · 259 阅读 · 0 评论 -
POJ1159Palindrome(区间dp回文串最长公共子序列+滚动数组模板)
PalindromeTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 62457 Accepted: 21761DescriptionA palindrome is a symmetrical string, that is, a string read i原创 2017-04-05 22:26:29 · 558 阅读 · 0 评论 -
POJ - 1050 To the Max(区间DP最大字串和,最大子矩阵和模板)
To the MaxTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 48400 Accepted: 25619DescriptionGiven a two-dimensional array of positive and negative integer原创 2017-04-05 22:17:27 · 471 阅读 · 0 评论 -
HDU - 1711(KMP模板)
Number SequenceTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25037 Accepted Submission(s): 10598Problem DescriptionGiven two s原创 2017-03-15 23:27:25 · 206 阅读 · 0 评论 -
POJ2063Investment
InvestmentTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 10506 Accepted: 3693DescriptionJohn never knew he had a grand-uncle, until he received the not原创 2017-04-01 23:58:36 · 227 阅读 · 0 评论 -
HDU114Piggy-Bank(完全背包模板题)
Piggy-BankTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23622 Accepted Submission(s): 11962Problem DescriptionBefore ACM can do原创 2017-04-01 23:54:39 · 369 阅读 · 0 评论 -
POJ3670Eating Together(LIS最长(非)上升(下降)子序列模板)
Eating TogetherTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6034 Accepted: 2941DescriptionThe cows are so very silly about their dinner partners. The原创 2017-04-10 21:45:40 · 424 阅读 · 0 评论 -
POJ-2823Sliding Window(单调队列模板)
Sliding WindowTime Limit: 12000MS Memory Limit: 65536KTotal Submissions: 58321 Accepted: 16711Case Time Limit: 5000MSDescriptionAn array of size n ≤ 106 i原创 2017-03-01 23:57:23 · 232 阅读 · 0 评论 -
E. Anton and Tree(缩点+树直径模板)
E. Anton and Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton is growing a tree in his garden. In原创 2017-03-01 23:58:59 · 496 阅读 · 0 评论 -
HDU3410 Passing the Message(单调队列模板)
Passing the MessageTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 715 Accepted Submission(s): 471Problem DescriptionWhat a sunny d原创 2017-03-02 23:45:56 · 267 阅读 · 0 评论 -
hdu1231最大连续子序列(dp模板最大连续子序列)
最大连续子序列Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31686 Accepted Submission(s): 14213Problem Description给定K个整数的序列{ N1, N2, .原创 2017-04-16 21:17:59 · 275 阅读 · 0 评论 -
2016-2017 ACM-ICPC, NEERC, Central Subregional Contest J.Architect of Your Own Fortune
题目大意:寻找luckynumber,她的定义是从n和m中各挑选一个六位数,使之n中的前三位之和与m中的后三位之和相同或者n中的后三位之和与m中的前三位之和相同,已经被选中的无法再组合,要是上面两种情况同时符合,选择和最大的一组,要是前者符合条件,在输出的时候输出AT和选中的两个六位数,否则是TA选中的两个六位数,排在前面的优先输出,然后按照第一个六位数的降序排列解题思路:这是一道二分图的题,原创 2017-05-11 10:40:03 · 396 阅读 · 0 评论 -
POJ3671Dining Cows(LIS)
Dining CowsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8420 Accepted: 3538DescriptionThe cows are so very silly about their dinner partners. They ha原创 2017-04-20 22:10:12 · 489 阅读 · 0 评论 -
HDU2639 Bone Collector II(01背包变形)
级第42届ACM国际大学生程序设计竞赛全球总决赛Bone Collector IITime Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5490 Accepted Submission(s): 2901原创 2018-02-05 15:17:36 · 138 阅读 · 0 评论 -
Codeforces Round #442 (Div. 2)B. Nikita and string(字符串,贪心)
B. Nikita and stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Nikita found the string contai原创 2018-01-23 18:21:15 · 223 阅读 · 0 评论 -
Educational Codeforces Round 34 (Rated for Div. 2)D. Almost Difference(数学)
D. Almost Differencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's denote a functionYou are原创 2018-01-22 21:48:39 · 192 阅读 · 0 评论 -
Educational Codeforces Round 34 (Rated for Div. 2)B. The Modcrab(贪心)
B. The Modcrabtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVova is again playing some computer game, now原创 2018-01-22 21:44:49 · 156 阅读 · 0 评论 -
Codeforces Round #422 (Div. 2) C. Hacker, pack your bags!(扫描线)
C. Hacker, pack your bags!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's well known that the best wa原创 2017-08-03 10:59:00 · 241 阅读 · 0 评论 -
Codeforces Round #427 (Div. 2) C. Star sky(前缀和)
C. Star skytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Cartesian coordinate system is set in the s原创 2017-08-03 10:54:48 · 194 阅读 · 0 评论 -
AtCoder Beginner Contest 061 D - Score Attack(最短路变形,Bellman-Ford最短路算法)
D - Score AttackTime limit : 2sec / Memory limit : 256MBScore : 400 pointsProblem StatementThere is a directed graph with N vertices and M edges. The i-th edge (1≤i≤M) points原创 2017-05-19 21:41:16 · 464 阅读 · 0 评论 -
2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南) 暨 第九届湘潭市大学生程序设计比赛H.Highway(树的直径)
HighwayAccepted : 122 Submit : 393Time Limit : 4000 MS Memory Limit : 65536 KBHighwayIn ICPCCamp there were n towns conveniently numbered with 1,2,…,n c原创 2017-05-18 21:13:40 · 1372 阅读 · 0 评论 -
Codeforces Round #319 (Div. 2)B. Modulo Sum(数学,DP)
B. Modulo Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence of numbers a1, a2, .原创 2017-05-18 21:03:37 · 308 阅读 · 0 评论 -
CS Academy E.Triplet Min Sum(最近公共祖先 倍增法模板)
Triplet Min SumTime limit: 2500 msMemory limit: 128 MBYou are given a tree with NN nodes. Answer QQ queries of the type:Given three distinct nodes AA, BB, and CC, find the原创 2017-05-26 21:09:13 · 287 阅读 · 0 评论 -
POJ2186Popular Cows(强连通分量分解模板)
Popular CowsTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 33426 Accepted: 13615DescriptionEvery cow's dream is to become the most popular cow in the h原创 2017-05-05 22:47:45 · 374 阅读 · 0 评论 -
POJ1985Cow Marathon(求树的直径模板)
Cow MarathonTime Limit: 2000MS Memory Limit: 30000KTotal Submissions: 5253 Accepted: 2574Case Time Limit: 1000MSDescriptionAfter heari原创 2017-03-02 23:49:05 · 225 阅读 · 0 评论 -
Soldier and Number Game--筛素数
D. Soldier and Number Gametime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo soldiers are playing a game.原创 2017-01-25 12:00:33 · 225 阅读 · 0 评论 -
A1. Oh Sweet Beaverette
A1. Oh Sweet Beaverettetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output— Oh my sweet Beaverette, would you fancy a walk along a原创 2017-03-12 23:44:51 · 295 阅读 · 0 评论 -
Ivan and Powers of Two
Ivan has got an array of n non-negative integers a1, a2, ..., an. Ivan knows that the array is sorted in the non-decreasing order.Ivan wrote out integers 2a1, 2a2, ..., 2an on a piece of paper.原创 2017-03-12 23:31:59 · 222 阅读 · 0 评论 -
POJ3661running
RunningTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6818 Accepted: 2532DescriptionThe cows are trying to become better athletes, so Bessie is running原创 2017-03-24 10:10:13 · 290 阅读 · 0 评论 -
POJ3660Cow Contest(floyed算法模板)
Cow ContestTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11015 Accepted: 6128DescriptionN (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are particip原创 2017-03-27 21:56:56 · 341 阅读 · 0 评论 -
C. Dima and Salad
C. Dima and Saladtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDima, Inna and Seryozha have gathered in a原创 2017-03-08 23:29:13 · 244 阅读 · 0 评论 -
HDU2087剪花布条
剪花布条Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 19173 Accepted Submission(s): 12054Problem Description一块花布条,里面有些图案,另有一块直接可用的小原创 2017-03-17 22:52:49 · 160 阅读 · 0 评论 -
Soldier and Number Game
D. Soldier and Number Gametime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo soldiers are playing a game.原创 2017-01-25 12:22:16 · 253 阅读 · 0 评论 -
Partitioning by Palindromes
题目大意:给你 T 组字符串 str,问你每个字符串的子字符串是回文串的最小个数 数据范围:1 涉及算法:DP(动态规划) 动态规划算法通常基于一个递推公式及一个或多个初始状态,当前子问题的解将由上一 次子问题的解推出,使用动态规划来解题只需要多项式时间复杂度,因此他比回溯法,暴力 法等要快许多 大致思路是: 1.要先找到初状态和末状态,通过原创 2017-01-25 12:21:09 · 262 阅读 · 0 评论 -
RMQ---Balanced Lineup
RMQ是在给定的一个区间内最值查询的一个算法,主要包括处理和查询两个部分,在预处理中,用的是动态规划去处理,首先设A[i]是要求区间最值的数列,F[i, j]表示从第i个数起连续2^j个数中的最大值,且F[i,0]就等于A[i],为了高效,把F[i, j]分为两半,F[i,j]就是这两段各自最大值中的最大值,所以状态转移方程F[i, j]=max(F[i,j-1], F[i + 2^(j-1)原创 2017-01-21 23:47:31 · 212 阅读 · 0 评论 -
并查集----The Suspects
并查集是将一些数据进行合并操作,一开始的时候每个人都是单独独立的,然后根据条件,进行合并,合并后会有些元素的根不再是自己了,同时多棵树也会根据要求变成一棵树,在完成这些条件后,就可以完成问题中的查询得到结果关键点如下:1.存在一个数组per[]用来存储每个元素的根,切记每次要进行初始化,初始化的要求是每个元素的初始化的根是自己//根和高度的初始化for (i = 0; i {原创 2017-01-21 23:41:34 · 231 阅读 · 0 评论 -
A. Magical Boxes
A. Magical Boxestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEmuskald is a well-known illusionist. One原创 2017-02-17 19:44:44 · 264 阅读 · 0 评论 -
LightOJ - 1422 Halloween Costumes(区间DP模板)
B - Halloween Costumes LightOJ - 1422 a题目大意:给你n个数,每个数意味着一件衣服,你可以套多件衣服,但是一旦脱下来某件衣服,之后要是遇到这件衣服,必须重新穿一个新的,一共至少穿几个衣服解题思路:这道题是个区间DP,区间DP一般有三层循环,第一层循环是区间的长度,第二层循环是区间头尾位置,第三层循环是在区间中找个中间值比较求极值原创 2017-04-08 16:09:01 · 528 阅读 · 0 评论