ACM
o詤o訁o
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #274 B. Towers
题目链接:http://codeforces.com/contest/479/problem/B题意:给你n个数,最多经过k次操作(每次操作对两个数,一个数加1,另一个数减1)问在不超过k次操作的过程中,计算出n个数中最大数与最小数的差值。。。注意这题是个特判题。。。。思路:先升序排序,对每次操作,我们对最大和最小的两个数进行操作,操作完后又进行排序。。。如果遇到最大与最小数的原创 2014-10-19 23:38:53 · 1116 阅读 · 0 评论 -
hdu 2072 单词数(STL set写法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072思路简单,但是注意一个细节就是最后可能是空格结束的,就是这儿让我WA啦好多次呀。。。code:#include#include#include#include#include#include#includeusing namespace std;int原创 2014-09-22 21:38:13 · 749 阅读 · 0 评论 -
poj 2503 Babelfish(STL map写法)
题目链接:http://poj.org/problem?id=2503题目大意:就是给你一本词典,问你能否在词典中找到你要查询单词的意思,不能就输出eh思路:map的入门级题,直接词典中的词组存到map中,然后直接查询。就是有些细节需要注意code:#include#include#include#include#includeusing nam原创 2014-09-22 21:35:40 · 1055 阅读 · 0 评论 -
poj 1363 Rails(STL应用)
题目链接:http://poj.org/problem?id=1363原创 2014-09-22 21:29:42 · 699 阅读 · 0 评论 -
poj 2051 Argus(优先队列)
//2014-7-6#include#include#includeusing namespace std;struct Node{ int num,per,sum; bool operator<(const Node& a) const { return sum>a.sum||(sum==a.sum&&num>a.num); }原创 2014-07-06 19:20:48 · 587 阅读 · 0 评论 -
poj 2431 Expedition(优先队列)
题目链接:http://poj.org/problem?id=2431原创 2014-07-06 17:50:54 · 682 阅读 · 0 评论 -
hdu 1711 Number Sequence:(KMP)
Number SequenceTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9850 Accepted Submission(s): 4501Problem DescriptionGiven two原创 2014-04-26 12:32:11 · 671 阅读 · 0 评论 -
六之再续:KMP算法之总结篇(12.09修订,必懂KMP)
续:KMP算法之总结篇(必懂KMP)作者:July。出处:http://blog.csdn.net/v_JULY_v/。引记 此前一天,一位MS的朋友邀我一起去与他讨论快速排序,红黑树,字典树,B树、后缀树,包括KMP算法,唯独在讲解KMP算法的时候,言语磕磕碰碰,我想,原因有二:1、博客内的东西不常回顾,忘了不少;2、便是我对KMP算法的理解还不够彻底,自不用说讲解转载 2014-04-26 12:38:32 · 733 阅读 · 0 评论 -
hdu 1232(并查集)
#include#include#includeusing namespace std;int f[1010];int find(int x){ if(f[x]!=x) { f[x]=find(f[x]); } return f[x];}void make(int a,int b){ int f1=find(a);原创 2014-04-05 10:45:45 · 596 阅读 · 0 评论 -
zoj 3669 Japanese Mahjong I
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3669题目大意:就是给你一副牌,问你胡牌的方式有几种,并输出方式。。。。。思路:因为一副牌的数量不多,所以可以直接枚举每一张牌,判断加上这张牌后能否胡牌。。。code:#include#include#include#include#原创 2014-08-27 11:41:47 · 1161 阅读 · 0 评论 -
hdu 1035 Robot Motion(dfs)
Problem DescriptionA robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. The possible instructio原创 2014-03-26 16:03:37 · 507 阅读 · 0 评论 -
hdu 4268 Alice and Bob(multiset)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4268题目大意:就是问你Alice的牌能覆盖Bob牌最多数量。牌不能翻转思路:首先我们不分种类,把牌按高度排序,然后我们在依次判断牌的种类,如果是Bob的牌,我们就他牌的宽度放入multiset中,如果是Alice的牌就在multiset中找到宽度最大的那一张并删掉。#include原创 2014-09-25 21:50:08 · 775 阅读 · 0 评论 -
uva 11995 - I Can Guess the Data Structure!(STL应用)
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=3146&mosmsg=Submission+received+with+ID+14262472I Can Guess the Data Structure!原创 2014-09-25 21:58:18 · 1078 阅读 · 0 评论 -
hdu 4902 Task schedule(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4907解题思路:就是把空余的时间单独用一个数组存起来,然后查找时用二分查找。但是这题却WA啦好多次,当时想死的心都有啦,后面才发现时数组开小了。。。code:#include#include#include#include#includeusing namespa原创 2014-08-04 08:41:22 · 841 阅读 · 0 评论 -
Codeforces Round #274 A. Expression
题目链接:http://codeforces.com/contest/479/problem/A题意:用加,乘两种操作算出算术式的最大值,可以加括号。。。思路:直接暴力枚举。。。。code:#include#include#include#include#includeusing namespace std;int main(){ int a,b,c;原创 2014-10-19 23:34:44 · 748 阅读 · 0 评论 -
Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift
题目链接:http://codeforces.com/contest/454/problem/B解题思路:这题我们只需要判断有几个a[i]#include#include#include#includeusing namespace std;int a[100010];int main(){ int n,i,j,k; while(scanf("%d",&n原创 2014-08-02 08:37:13 · 1353 阅读 · 5 评论 -
Codeforces Round #258 (Div. 2) B. Sort the Array
题目链接:http://codeforces.com/contest/451/problem/B思路:首先找下降段的个数,如果下降段是大于等于2的,那么就直接输出no,如果下降段的个数为1,那么就把下降段的起始位置和结束位置记录下来然后进行判断,在进行判断时,有几种特殊情况:(s表示起始位置,e表示结束位置)1.当e==n&&s!=1时,满足a[n]>a[s-1]输出yes;2原创 2014-07-25 08:28:07 · 723 阅读 · 0 评论 -
Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences
题目链接:http://codeforces.com/contest/450/problem/B思路:当看到这个数列时我的第一感觉就是找公式,但是找啦一会没找出来,于是就想可能是找规律,就把测试数据继续写下去,发现这是一个周期为6的周期数列code#include#include#define m 1000000007using namespace std;原创 2014-07-20 08:19:48 · 645 阅读 · 0 评论 -
Codeforces Round #256 (Div. 2) D. Multiplication Table
题目链接:http://codeforces.com/contest/448/problem/D原创 2014-07-18 14:23:33 · 675 阅读 · 0 评论 -
poj 3268 Silver Cow Party(dijkstra最短路)
题目链接:http://poj.org/problem?id=3268题目大意:给你N个农场,在X农场要举办一个party,其它农场需要到X农场去,然后还要回来,问N个农场中距离最远的那个至少为多少?,给出的边为单向边。。。思路:用dijkstra最初X农场到其它几个农场的最短距离,然后在把边反向,继续求出X到其它几个农场的最短距离,算出最大的那一个。。。code:#inc原创 2014-09-25 21:36:16 · 747 阅读 · 0 评论 -
poj 1789 Truck History(kruskal算法)
题目链接:http://poj.org/problem?id=1789思路:把每一行看成一个一个点,每两行之间不懂得字符个数就看做是权值。然后用kruskal算法计算出最小生成树我写了两个代码一个是用优先队列写的,但是超时啦,不知道为什么,希望有人可以解答。后面用的数组sort排序然后才AC。code:数组sort排序AC代码:#include#include#includ原创 2014-07-17 19:24:22 · 697 阅读 · 0 评论 -
poj 2456 Aggressive cows(二分查找)
题目链接:http://poj.org/problem?id=2456题目大意:给你n个坐标,求c个坐标中最小的最大距离。思路:这题跟poj3273有点是差不多的方法,不过要先把坐标排序,然后用在最短距离跟最大距离之间进行查找,每次二分判断最小距离为mid的个数code:#include#include#include#include#includeusing原创 2014-09-26 21:40:26 · 4166 阅读 · 0 评论 -
poj 3273 Monthly Expense(二分查找)
题目链接:http://poj.org/problem?id=3273题目大意:给你n个数把他们连续的分成m组,问最小的那一组的最大值。思路:用最小的那一个元素和总和进行二分。。。然后判断最小那组为mid时,分组的个数。#include #include #include #include #include using namespace std;int a[1原创 2014-09-26 21:35:24 · 3979 阅读 · 4 评论 -
poj3122 Pie(二分查找)
题目链接:http://poj.org/problem?id=3122题目大意:有N个蛋糕,要分给F+1个人,要求面积相等且每个人得到的是一整块而不是拼接而成的。思路:每个人分到的面积范围为[0,s总/(F+1)],所以就从最大的那一个开始分,并计算出按此面积能分出多少块。。。。特别注意这题,开始WA啦很多次就是因为pi的取值,pi取3.1415926精度还不行,要更高才行。。。。还坑原创 2014-09-11 11:17:02 · 809 阅读 · 0 评论 -
poj 1962 Corporative Network(并查集)
题目链接:http://poj.org/problem?id=1962思路:每个集合中用根节点标记这个集合,每个点到根节点的距离。code:#include#include#include#include#include#includeusing namespace std;const int maxn=20005;int pa[maxn],d[maxn];i原创 2014-09-29 10:36:49 · 747 阅读 · 0 评论