
贪心策略/决策问题
等我学会后缀自动机
侠影之谜
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
CodeForces 582A GCD Table (分析状态+贪心)
题目链接:http://codeforces.com/problemset/problem/582/A题目大意给定一个序列的GCD table的乱序,GCDtable的定义十分简单形象,要求根据这个table 序列还原出原来的序列.题目分析我们可以发现,table中最大的一个数肯定是序列中的一个数,这样状态就可以根据当前情况缩减了!!假设我们已经得知前k个数...原创 2019-04-24 18:47:49 · 245 阅读 · 0 评论 -
HDU 3183 A Magic Lamp (贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-12-07 00:39:37 · 396 阅读 · 0 评论 -
HDU 6178 Monkeys (匹配数+贪心)*
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6178#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-12-09 00:42:39 · 199 阅读 · 0 评论 -
Gym 101142F Folding (贪心)
题目链接:http://codeforces.com/gym/101142/attachments#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long ...原创 2018-12-09 00:12:15 · 154 阅读 · 0 评论 -
Codeforces Round #525 (Div. 2)E.(树形DP+贪心)
题目链接:http://codeforces.com/contest/1088/problem/F#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll __in...原创 2018-12-05 23:02:15 · 221 阅读 · 2 评论 -
CodeForces 767D Cartons of milk (贪心+二分)
题目链接:http://codeforces.com/problemset/problem/767/D#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll uns...原创 2018-11-18 14:18:51 · 283 阅读 · 0 评论 -
ZOJ 4035 Doki Doki Literature Club (水)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4035#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x...原创 2018-11-18 12:05:20 · 283 阅读 · 0 评论 -
HDU 5881 Tea (贪心+细节)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5881#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lo...原创 2018-11-19 18:41:38 · 156 阅读 · 0 评论 -
CodeForces 767B The Queue (贪心+细节)好题
题目链接:http://codeforces.com/problemset/problem/767/B#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lo...原创 2018-11-19 17:47:07 · 191 阅读 · 0 评论 -
HDU 6326 Problem H. Monster Hunter (贪心+优先队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6326#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-11-08 11:16:07 · 246 阅读 · 0 评论 -
Codeforces 1066D Boxes Packing (模拟+题意。。。)
题目链接:http://codeforces.com/problemset/problem/1066/D#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lo...原创 2018-10-27 10:58:54 · 320 阅读 · 0 评论 -
Codeforces 1072C Cram Time (贪心)
题目链接:http://codeforces.com/problemset/problem/1072/C#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lo...原创 2018-10-27 07:54:10 · 251 阅读 · 0 评论 -
HDU 6301 Distinct Values (贪心+维护区间)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6301#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define mst(a,...原创 2018-10-30 09:28:49 · 128 阅读 · 0 评论 -
CodeForces - 496E Distributing Parts (贪心+数据结构应用)
题目链接:http://codeforces.com/problemset/problem/496/E#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-10-16 16:51:13 · 223 阅读 · 0 评论 -
Gym 101550D Daydreaming Stockbroker (贪心)
题目链接:http://codeforces.com/gym/101550/attachments#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long ...原创 2018-12-07 00:41:40 · 262 阅读 · 0 评论 -
HDU 6188 Duizi and Shunzi (贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-12-07 00:45:35 · 135 阅读 · 0 评论 -
HDU 6180 Schedule (贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6180#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-12-10 09:58:53 · 203 阅读 · 0 评论 -
CodeForces 713C Sonya and Problem Wihtout a Legend (策略问题+DP)*
题目大意给定一个序列,现在有两种操作,一种是使序列中某一个数加一,一种是使其减一.问把这个序列弄成单调递增的最少操作次数是多少.题目分析这题我是看题解的,发现是蛮经典的一道题.首先考虑不降序列,那么我们如果暴力DP那么数据范围是九次方存不下,我们需要找到一种可以包含所有可能转移到的状态的空间而使空间开的下.我们可以证明序列最后映射成的,是其原本序列的子集...原创 2019-04-28 19:11:24 · 245 阅读 · 0 评论 -
Codeforces Round #551 (Div. 2)D D. Serval and Rooted Tree(树形DP+贪心)*
题目链接:http://codeforces.com/problemset/problem/1153/D题目大意给定一颗树结构,每个节点上设置了max和min标志,意味着该节点的值取其son的最大/最小值,而叶节点上的数取值为1到叶节点总个数并且各不相同.要求根节点值最大是多少.题目分析思考dp值,那么毫无疑问dp转移关系核心在min和max函数之间,考虑到...原创 2019-04-18 19:37:25 · 153 阅读 · 0 评论 -
Codeforces Round #550 (Div. 3) G. Two Merged Sequences(贪心)
题目链接:http://codeforces.com/contest/1144/problem/G题目大意给定一个序列,要求判断是否能把其按序分解成两个子序列,一个递增一个递减,如果能,输出01序列,1代表递增的,0代表递减的子序列.题目分析是我薄弱的环节即策略问题.正解是贪心,首先分析子状态性质,假如最后可以存在一个答案,那么对于任何1到i的序列肯...原创 2019-04-26 17:01:46 · 172 阅读 · 0 评论 -
Codeforces Round #551 (Div. 2) C Serval and Parenthesis Sequence (贪心策略)
题目链接:http://codeforces.com/contest/1153/problem/C题目大意给定括号串和问号,问号可以填入左括号和右括号,问是否可以把这个串改成:任何前缀括号序列不合法但整体合法的序列.题目分析这道题是贪心做法.首先我们不难发现输入长度为奇数或者原先左括号数量大于一半长度或右括号长度大于一半长度肯定无解.那么我们可以知道还需...原创 2019-04-14 18:43:49 · 181 阅读 · 0 评论 -
Codeforces Global Round 2 E. Pavel and Triangles(贪心+DP思想)*
题目链接:http://codeforces.com/contest/1119/problem/E题目大意给定价值为2的幂次方的长度的数量序列,问最多能拼成多少个合法三角形。题目分析不难利用幂次方级数的性质发现,构成三角形只有两种情况,三种选一样的,和两个一样的加上一个次小的。基于这样的情况,我们考虑当前位置数量,按2选取的话肯定是贪心的能选多少就选多少,但我们...原创 2019-04-07 22:57:34 · 179 阅读 · 0 评论 -
Codeforces Round #546 (Div. 2)D - Nastya Is Buying Lunch (贪心+排序)
题目链接:http://codeforces.com/contest/1136题目大意给定一个队列序号,小明在队尾,给定若干个序对,每个序对(a,b)表示a如果在b前面一个位置则可以调换这两人的位置i,问小明最多可以往前进多少。题目分析贪心思想,对于一个位置,假设可以和这个位置替换的若干个位置,不难发现这些位置的相对位置是不变的,那么我们用vector把每个标号其...原创 2019-03-13 19:16:05 · 231 阅读 · 0 评论 -
Educational Codeforces Round 61 (Rated for Div. 2) D. Stressful Training(贪心+二分+优先队列)
题目链接:http://codeforces.com/contest/1132/problem/D题目大意每个同学电脑有初始电量和电量消耗速度,这堂课有k分钟,其损耗过程有note描述。现在有个输出x,每分钟可以指定一个电脑并充电x,问要维护每位同学电脑电量始终不小于零,其最小的x是多少。题目分析这道题思路倒是蛮容易想的,就是细节比较多!可以看出是二分,并且二分上界是...原创 2019-03-16 19:26:10 · 300 阅读 · 0 评论 -
Codeforces Round #545 (Div. 2) D. Camp Schedule(KMP思想+贪心)
题目链接:http://codeforces.com/contest/1138/problem/D题目大意背景不读,只把编程要求领出来,就是给定两个串,把第一个串重新组合使得第二个串在其中出现的次数最多。题目分析明显的kmp题目,我们利用下nxt数组的求法,这样我们可以找到一个长度,这个长度代表着原串前后缀一样的最大长度且长度小于串长度,那么我们不难发现,可以得到...原创 2019-03-09 17:38:40 · 242 阅读 · 0 评论 -
Codeforces Round #542 (Div. 2) D2. Toy Train(思维+贪心)
题目链接:http://codeforces.com/contest/1130/problem/D2题目大意考虑特定的一个站台,其要完成k个糖果的配送并要送往x1,x2,..xk,我们通过手动模拟不难发现要想最优的完成这个站台的配送,最后到达的点是离当前点最近的x值。并且有几个糖果就转几圈,如果在x集合中出现了比当前站台序号大的,那么圈数减一。题目分析 对于离站台的...原创 2019-02-27 15:35:51 · 143 阅读 · 0 评论 -
CodeForces 645E Intellectual Inquiry (DP+贪心)
题目链接:http://codeforces.com/problemset/problem/645/E题目大意:给定n和k和一个串,表示有k个字符可以选择,还可以选择n个字符,问选择完后的字符串其不同的子序列数量有多少个。题目分析: 首先来分析原先给定的序列,令dp[i]表示到i位置的不同子序列个数,那么新增的字母x,我们只要减去因为这个字母造成的重复度即可,假设这个...原创 2019-02-17 13:15:19 · 215 阅读 · 0 评论 -
Gym 101102L Starry Night (树形DP+贪心)
题目链接:http://codeforces.com/gym/101102/problem/L#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long lo...原创 2019-02-09 08:31:51 · 228 阅读 · 0 评论 -
Codeforces Round #537 (Div. 2)B. Average Superhero Gang Power (贪心+暴力)
题目链接:http://codeforces.com/contest/1111/problem/B#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long ...原创 2019-02-04 19:59:47 · 567 阅读 · 0 评论 -
CodeForces 66E Petya and Post (线性DP+数学思维)
题目链接:http://codeforces.com/problemset/problem/66/E#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long...原创 2018-12-10 10:06:53 · 289 阅读 · 0 评论 -
ZOJ 3905 Cake (贪心+简单DP)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3905#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x...原创 2018-10-18 17:45:44 · 250 阅读 · 0 评论 -
HDU 5501 The Highest Mark (贪心+背包DP)*
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5501#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-10-18 12:31:41 · 189 阅读 · 0 评论 -
Codeforces 864D Make a Permutation! (贪心+维护)思维好题
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) ...原创 2018-07-27 11:25:24 · 250 阅读 · 0 评论 -
多校练习赛2 D money (简单贪心思想)
链接:https://www.nowcoder.com/acm/contest/140/D来源:牛客网 题目描述White Cloud has built n stores numbered from 1 to n.White Rabbit wants to visit these stores in the order from 1 to n.The store numbered...原创 2018-07-21 22:22:44 · 389 阅读 · 0 评论 -
UVA 11572 Unique Snowflakes (贪心技巧)
Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a machine that captures snowflakes as they fall, and serializes them into a stream of snowflakes that flo...原创 2018-07-16 10:08:09 · 327 阅读 · 0 评论 -
UVA 11054 Wine trading in Gergovia (贪心技巧)
As you may know from the comic “Asterix and the Chieftain’s Shield”, Gergovia consists of one street, and every inhabitant of the city is a wine salesman. You wonder how this economy works? Simple eno...原创 2018-07-15 18:51:17 · 270 阅读 · 0 评论 -
UVA 1471 Defense Lines (高效算法分析序列性质)*
After the last war devastated your country, you - as the king of the land of Ardenia - decided it was high time to improve the defense of your capital city. A part of your fortification is a line of ma...原创 2018-07-18 07:44:14 · 205 阅读 · 0 评论 -
UVA 120 Stacks of Flapjacks(算法设计技巧)
Stacks and Queues are often considered the bread and butter of data structures and find use in architecture, parsing, operating systems, and discrete event simulation. Stacks are also important in the...原创 2018-06-29 09:44:49 · 148 阅读 · 0 评论 -
Codeforces educational round 46 B Light It Up(贪心+维护变量)
B. Light It Uptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, you bought a brand new smart lamp with programming features. At first, you ...原创 2018-06-28 06:38:37 · 468 阅读 · 0 评论 -
Codeforces 373C Counting Kangaroos is Fun(双游标贪心)
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least t...原创 2018-06-27 18:31:02 · 215 阅读 · 0 评论