自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

yueqiq

仗义每多屠狗辈,负心多是读书人

  • 博客(20)
  • 收藏
  • 关注

原创 usaco Contact

暴力code:/*ID: yueqiPROG: contactLANG: C++*/#include #include #include #include #include #include #define LL __int64using namespace std;bool cmp(const pair &a,const pair &b){ if (a.fir

2012-09-27 20:36:14 770

原创 hdu4882 Coder

基本上算是抄的代码。。。。线段树,维护一个sum数组,sum数组存的是当前区间段以第1-5个数为起点的间隔为5的数的总和离线化处理也是以前从没有见过的code:#include #include #include #include #define LL __int64using namespace std;const int MAXN = 110005;struct

2012-09-27 19:41:36 355

原创 hdu1800 flying to the mass

又被水题虐了。。。。。。给你一堆士兵的等级,等级高的的士兵可以当等级小的士兵的师傅,一个士兵最多一个师傅(可以没有),一个师傅最多1个徒弟(可以没有),如果是师徒关系,可以用一把扫帚练习技能,问你如果全部士兵都用过扫帚练习时最小需要的扫帚数量。刚开始打算直接贪心的。。复杂度太高,tle了,,然后百度才发现所求的竟然就是出现最多的那一个数,即最长平台.用map做其实爆简单。。。code:#i

2012-09-25 17:58:39 396

原创 hdu1509 Windows Message Queue

优先队列水题,真心不懂那个code:#include #include #include using namespace std;struct Win{ char name[50]; int id,val,parameter; friend bool operator < (Win a,Win b) { if(a.val==b.v

2012-09-24 16:06:11 402

原创 hdu3038 How Many Answers Are Wrong

并查集真心高深,偏移量的问题以及路径压缩中的更新顺序问题真心把我搞迷糊了。。。。决定先不看并查集了。。。。code:#include #include using namespace std;class UFS{ static const int MAXN = 200001;public: int father[MAXN]; int rank[MAXN]

2012-09-24 15:02:17 394

原创 hdu3635 Dragon Balls

智商拙计啊,这题看了解题报告都不是很懂,郁闷。。。。。考虑了很长时间,才明白每个根结点最多只能移动一次,所以我们的目的就是把这一次push到各个子节点上就可以了,因为路径压缩的缘故,除了这次操作之外,所有的结点都挂在根节点上,完全水题一枚,被暴虐啊code:#include #include using namespace std;const int MAXN =

2012-09-24 13:18:40 320

原创 poj1281 棋盘游戏

这题应该算是一道比较简单的二分图问题,可是我压根还是没想到二分图,一看解题报告说用二分图,再一琢磨就明白了。。。。就是求二分图的最大匹配和关键匹配code:#include #include using namespace std;int n,m,k;int link[101];bool graph[101][101],vis[101];struct pos{ i

2012-09-23 22:41:38 640 1

原创 hdu1573 X问题

今天一早晨都花在这题上了,昨天晚上看了一晚上终于把数论回忆了一下思路:解模不互质的线性同余方程组,wa了一早晨不知道哪里错了,估计是所有数的lcm求错了???不解,后来没有独立的求lcm,而是用合并方程的最后一个lcm就AC了,(主要是一开始没想到用这个。。。还另外求,智商拙计啊)code:#include #include #include #define LL __int

2012-09-22 10:11:45 497

原创 hdu4091 Zombie’s Treasure Chest

跟省赛差不多的一道题,贪心+背包,对于一个最小公倍数,肯定有最优解。#include #include #include #define LL __int64using namespace std;LL gcd(LL a, LL b){ return b ? gcd( b, a % b) : a;}LL lcm(LL a, LL b){ return

2012-09-21 20:33:12 923

原创 hdu1558 Segment set

屌丝真心觉得这题的计算几何味道远大于并查集,花了两天时间才想明白怎么判断两条直线相交,结果还写不对,。。。。。code:#include #include using namespace std;const double eps=1e-8;int decmp(double n){ if(fabs(n)<eps) { return 0;

2012-09-21 13:24:05 341

原创 hdu4291 A Short problem

完全被虐啊,见识太少,完全没有意识到取模必定会有循环节的问题,所以束手无策。。。。。先暴力本地算出最外层取模的循环节,在依次往里推循环节,还需要注意两个long long型相乘的溢出问题,不过这道题好像没有这么极端的数据code:#include #include #define LL __int64using namespace std;LL modular_multi(

2012-09-18 22:53:40 328

原创 hdu2527 Safe Or Unsafe

哈夫曼编码问题,因为只需要求权值,所以不必建立哈夫曼数,只需要按照贪心的思想求权就可以code:#include #include #include using namespace std;char buf[100];multiset s;int n,cnt[26];//采用2进制的哈夫曼,clen进制数int huffman(char str[],int clen){

2012-09-15 16:01:22 586

原创 hdu2473 Junk-Mail Filter

并查集删点问题,牺牲空间换取时间,就是给每一个点找一个替代,删除的时候只需要把替代更换就可以了code:#include #include using namespace std;const int INF = 0x3fffffff;int n,m,fa[1000000],rank[100000],rep[1000000],ind;bool vis[1100000];vo

2012-09-08 09:04:12 522

原创 hdu1598 find the most comfortable road

很神奇的kruakal用法,枚举最小的边,然后kruakal找到一条可行路径,记录差值比较看了解题报告都有点晕,自己绝对想不到这种用法。。。。。code:#include #include using namespace std;const int INF = 0x3fffffff;int n,m,fa[201],rank[201];struct node{

2012-09-07 21:24:28 399

原创 hdu1873 看病要排队

主要是学习一下优先队列的使用code:#include #include using namespace std;struct node{ int id,lv; friend bool operator < (const node x,const node y) { if(x.lv==y.lv) {

2012-09-05 20:49:56 2575 1

原创 hdu1870 愚人节的礼物

刚开始看见一层一层的括号本能觉得是栈的应用,后来一想它给的括号嵌套肯定是合法的,所以遇上一个左括号+1,遇上一个右括号-1,遇上B输出就可以了。。。。code:#include #include using namespace std;char str[1001];int main(){ int len,i,cnt; while(~scanf("%s",str)

2012-09-05 20:15:45 648

原创 hdu1237 简单计算器

模拟栈运算,其实递归也可以,不过我够呛能写的出来其实老早就看过表达式求值的问题,只不过一直没有敲过,今天敲了一下,发现还是有不少问题的code:#include #include #include using namespace std;bool check(char,char);void solve();char str[205],ch;double tmp,a,b;

2012-09-05 15:36:49 1160

原创 hdu1142 A Walk Through the Forest

这题刚开始思考了半天却没想到什么好的办法,最后看了解题报告,发现我从一开始就没有记忆化搜索这方面的想法,我想到了求出每个点到终点的最短路,却没想到用记忆花搜索来解决路径条数思路:最短路+记忆化搜索code:#include #include #include #include using namespace std;const int INF = 0x3fffffff;in

2012-09-03 15:56:15 360

原创 hdu1425 sort

用堆排序写的,可能优化的不是很好,加上输入外挂才没有超时code://从今天开始不再用宏定义//采用松散的代码写法~~#include #include #include #include #include using namespace std;void swap(int &a1,int &a2){ int tmp=a2; a2=a1; a1=t

2012-09-01 11:51:35 499

原创 hdu As Easy As A+B

正如题目所说,这是一道像A+B一样简单的一道题,code://从今天开始不再用宏定义//采用松散的代码写法~~#include #include #include #include #include using namespace std;void swap(int &a1,int &a2){ int tmp=a2; a2=a1; a1=tmp;

2012-09-01 10:48:59 367

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除