题意: 给你B,C,S三种模式,当出现S时直接得分最多300(即perfect) 当是B,C时后面会跟一个数字,当后面的数字是从1开始的连续时,直接得分最多300(即perfect) 问给你一系列,最多能得到多少个pefect 思路: 当出现S时直接+,当出现B或者C时,判断它们后面是否有1,有则+ 做的时间想复杂了- - #include <cstdio> #include <cstring> #include <cstdlib> using namespace st…
题意: 给你四个矩形,判断能否从中选出3个组成一个矩形 思路: 1.搜索,如果两个能组成一个新的,则将他们合并,继续搜索 2.暴力判断 最开始没注意到3,一直以为要用4个,WR #include <cstdio> #include <cstring> #include <cstdlib> using namespace std; const int maxn = 10005; const int INF = 0x3f3f3f3f; int x[5]; int y[5];…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5558 Problem Description Alice wants to send a classified message to Bob. She tries to encrypt the message with her original encryption method. The message is a string S, which consists of Nlowercase let…
House Building Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 145    Accepted Submission(s): 123 Problem Description Have you ever played the video game Minecraft? This game has been one of t…
Chip Factory Time Limit: 18000/9000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 368    Accepted Submission(s): 202 Problem Description John is a manager of a CPU chip factory, the factory produces lots of chips…
Partial Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 228    Accepted Submission(s): 138 Problem Description In mathematics, and more specifically in graph theory, a tree is an undirect…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 186    Accepted Submission(s): 124 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl…
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 447    Accepted Submission(s): 201 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort,…
Rebuild Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 446    Accepted Submission(s): 113 Problem Description Archaeologists find ruins of Ancient ACM Civilization, and they want to rebuild i…
Count a * b Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 211    Accepted Submission(s): 116 Problem Description Marry likes to count the number of ways to choose two non-negative integers a…
Too Rich Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 245    Accepted Submission(s): 76 Problem Description You are a rich person, and you think your wallet is too heavy and full now. So yo…
Pagodas Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1282    Accepted Submission(s): 902 Problem Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3509    Accepted Submission(s): 1122 Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.Fo…
F - Almost Sorted Array Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5532 Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selectio…
其他的都先不说,北大的未名湖真的美! 虽然感觉北大其他地方都有些破旧之感,但是未名湖附近真的值得称赞. 在去北京之前就听说北京温度很低,不过是干冷,果不其然.北京不冷,就是嘴唇太干了,不喝水真的受不了,其实单单从温度来看,北京的冬天还是有点舒服的.北京地铁都是暖气,地铁里面还有高逼格的动态广告(第一次见,还在知乎上查了一下). 北大的伙食好便宜,比较我们学校而言,随便一根棒冰基本上就10块了,北大看了下棒冰的价钱都没超过5块的,手抓饼又便宜又好吃.食堂就不怎么好吃了(虽然便宜,但是听说我们是不能…
Kingdom of Black and White                                                                                                            Time Limit: 2000/1000 MS (Java/Others)                                                                             …
Ponds                                   Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                        Problem Description Betty owns a lot of ponds, some of them are connected with other…
5573 Binary Tree(构造) 题意:给你一个二叉树,根节点为1,子节点为父节点的2倍和2倍+1,从根节点开始依次向下走k层,问如何走使得将路径上的数进行加减最终结果得到n. 联想到二进制. 思路和这个差不多吧:http://blog.csdn.net/u013068502/article/details/50094561 #include <set> #include <queue> #include <cstdio> #include <vector…
5510 Bazinga 题意:给出n个字符串,求满足条件的最大下标值或层数 条件:该字符串之前存在不是 它的子串 的字符串 求解si是不是sj的子串,可以用kmp算法之类的. strstr是黑科技,比手写的kmp快.if(strstr(s[i], s[j]) == NULL),则Si不是Sj的子串. 还有一个重要的剪枝:对于一个串,如果当前找到的串是它的母串,则下一次这个串不用遍历. #include <set> #include <queue> #include <cst…
5532 Almost Sorted Array 题目大意:给你一个序列,如果它拿掉其中一个数后,可以是该序列成为非递减或非递增序列,则输出YES. 有两种思路,第一种代码比较简单,是LIS,复杂度nlogn,第二种是On的复杂度. LIS的代码如下. #include <set> #include <queue> #include <cstdio> #include <vector> #include <cstring> #include &l…
废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: 我没有读题,只是队友给我解释了题意,然后我根据题意写的题. 大概意思是给n个字符串,从上到下依次标记为1——n,寻找一个标记最大的串,要求这个串满足:标记比它小的串中至少有一个不是它的子串. 输入: 第一行输入一个整型t,表示共有t组数据. 每组数据首行一个整型n,表示有n个串. 接下来n行,每行…
题意: 给你一块正方形的土地,里面有矩形的草地,要求把土地分成两份,满足以下两个条件 1.两边的绿洲,左边>=右边,差值尽可能的小 2.在满足1的情况下分给左边的土地尽快能的多 而且绿洲不会出现覆盖 思路: 将绿洲压到你给一维矩阵中,然后从左往右加,当ls*2 >= sum,往后面寻找最近的一个p[i] != 0(即存在绿洲的地方) Orz: 第一次没对,就YY绿洲可能超出了土地范围,然后哦一直WA 现在才发现,当时只是没把有的数定义成long long超了,QAQ心好痛 #include &…
A - Pattern String 留坑. B - Bazinga 题意:找一个最大的i,使得前i - 1个字符串中至少不是它的子串 思路:暴力找,如果有一个串已经符合条件,就不用往上更新 #include <bits/stdc++.h> using namespace std; #define N 510 int t, n; int vis[N]; string s[N]; int main() { ios::sync_with_stdio(false); int t; cin >&…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5273 思路:二分枚举x. #include <cstdio> using namespace std; ; typedef long long LL; struct Rectangle{ int l, t, w, h; LL area; }rect[MA…
Almost Sorted Array Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted arr…
题目链接: pid=5527">http://acm.hdu.edu.cn/showproblem.php?pid=5527 题意&题解: 感觉自己真是弱啊,自己想的贪心是错的,根本没想到20,50的特判,╮(╯▽╰)╭ 附我參考的聚聚的题解: http://blog.csdn.net/snowy_smile/article/details/49592521 代码: (差点儿和那位聚聚的一样.ORZ) #include<iostream> #include<alg…
链接在这:http://bak.vjudge.net/contest/132442#overview. A题,给出a,b和n,初始的集合中有a和b,每次都可以从集合中选择不同的两个,相加或者相减,得到一个新的数,如果在1~n内的话就放入集合中,并算一次操作,谁先不能操作(所有新数已经存在于集合内的话就不能进行操作)者输.问谁会赢. 可以得到的数字为k*gcd(a,b),那么只要算出在1~n的范围内存在多少个这样的数字,判断一下奇偶性即可. B题,给出n个字符串,问最大的满足条件的字符串的位置,条…
n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (labelled aand b, where 1≤a≠b≤n) withstood the test of time. Two monks, Yuwgna and Iaka, decide to make…
题意:有\(n\)个点,\(m\)个集合,集合\(E_i\)中的点都与集合中的其它点有一条边权为\(t_i\)的边,现在问第\(1\)个点和第\(n\)个点到某个点的路径最短,输出最短路径和目标点,如果不满足条件则输出\(Evil John\). 题解:题目所给的边数关系太复杂了,我们可以让每个集合中的所有点都与一个虚拟节点连边,而这些点两两却不连,然后再去找\(1\)个和第\(n\)个点的最短路径,不难发现,最终得到的路径为\(dis[i]/2\),所以我们只要用虚拟节点建边然后跑两次dijk…
题意:给你\(n\)个字符串,\(s_1,s_2,...,s_n\),对于\(i(1\le i\le n)\),找到最大的\(i\),并且满足\(s_j(1\le j<i)\)不是\(s_i\)的子串. 题解:直接\(O(n^2)\)然后跑kmp匹配,这里注意要剪枝,不然会T,也就是说对于前\(i-1\)个串,如果它是后面某个串的子串,那么我们就不用对它跑kmp,因为它后面的某个串包含了它. 代码: int t; int n; string s[N]; int ne[N]; bool st[N]…