自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Cifer

永远在内心的最深处听见水手说 他说风雨中这点痛算什么 擦干泪不要怕至少我们还有梦 他说风雨中这点痛算什么 擦干泪不要问为什么 好水 好水 好水 好水 好水 好水 好水 好水 !!!!

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

原创 HDOJ 1272 小希的迷宫 (并查集)

题目链接:(=^ ^=)思路:判断2点是不是在一个集合(是的话不行, 不是可以), 如果不在一个集合最后还要判断所有的点是不是在一个集合。(以下用一个集合中的点数与出现的点数判断)(wa了半天结果是数组开小了 纠结)code:#include #include int rank[100002], father[100002], used[100002], flag

2012-04-27 11:18:29 434

原创 HDOJ 1873 看病要排队 (结构体快排)

题目链接:( ¯ □ ¯ )思路:用结构体排序, 按优先权从小到大, 如果优先权一样按ID号从大到小排code:#include #include typedef struct{ int level, num;}node;node quene[4][4004];int count1 = 0, count2 = 0, count3 = 0;int c

2012-04-24 14:58:38 859

原创 HDOJ 1254 推箱子(bfs+dfs)

题目连接:ヽ(ˋ▽ˊ)ノ思路:每个点不止可以走一次, 而是可以可以从不同的方向到达一次,(wa了n多次)code:#include #include typedef struct{ int x, y, count; int xx, yy;}node;node step, quene[1000];int map[10][10], used[

2012-04-21 20:11:59 550

原创 POJ 3253 Fence Repair (堆排序)

题目连接:~( ̄▽ ̄~)(~ ̄▽ ̄)~用堆排序建立小根堆每回选取2个最小的值相加,再把得到的值放回堆中排序code:#include int num[20009], n = 0;__int64 sum = 0, sum2 = 0;void sift(int l);void heapsort();int main(){ int i = 0; while

2012-04-17 16:18:13 674

原创 HDOJ 今年暑假不AC (贪心)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~思路:按结束时间排序code:#include #include typedef struct{ int x, y;}node;node num[102];int cmp(const void *a, const void *b){ return (*(node *)a).y-(*(node *)b).y;}int

2012-04-14 19:45:17 1173

原创 HDOJ 1789 Doing Homework again (贪心)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~code:#include #include #include typedef struct{ int dl, re;}node;node num[1005];int used[1005], n = 0, sum = 0;int cmp(const void *a, const void *b){ return

2012-04-14 18:04:05 451

原创 POJ 2528 Mayor's posters (线段树+离散化)

题目链接:ヽ(ˋ▽ˊ)ノ 哎~网上看了老久,才知道怎么离散化,郁闷,建树前需要离散化点, 用p[i][2]来存储每个点离散化前的信息, 用结构体num来存储每个点的具体信息code:#include #include #include typedef struct{ int num, id , left;//该点的数值, 为哪条线段的, 左端点还是右端点

2012-04-09 19:26:32 420

原创 HDOJ 1166 敌兵布阵 (线段树)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~哎~ 不会树状数组郁闷........╮(╯Д╰)╭code:#include typedef struct{ int l, r, count;}node;node tree[4*50005];void Init(int root, int left, int right){ int m = (left+righ

2012-04-07 19:41:41 472

原创 UVa 439 Knight Moves (bfs)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~水过~#include #include int map[10][10], used[10][10], X1 = 0, Y1 = 0, X2 = 0, Y2 = 0, sum = 0;int dir[8][2] = {{-1,-2},{1,-2},{-2,-1},{2,-1},{-2,1},{2,1},{-1,2},{1,2}};t

2012-04-07 12:56:45 488

原创 POJ 1321 棋盘问题 (dfs)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~水过~code:#include #include int n = 0, k = 0, sum = 0, count = 0,used[10];//用used来标记每列是否有棋子出现过char map[10][10];void dfs(int row)//传的是当前是第几行{ int i = 0; if(count

2012-04-07 11:04:23 458

原创 HDOJ 1495 非常可乐 (bfs)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~用bfs广搜,用2维数组used[102][102]来记录2杯子出现过的状态(判重),如果可乐量为奇数这种情况不可能分成相等的2份code:#include #include int s = 0, n = 0, m = 0, used[102][102], flag = 0;typedef struct{ int a,

2012-04-06 20:35:27 669

原创 HDOJ 1874 畅通工程续 (最短路)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~就是个最短路的问题又wa了ˋ^ˊ... 要判重边不说了,居然测试中有自己到自己的路ㄟ(▔,▔)ㄏ 初始化时要弄成0或s == t时输出0。code:#include #define Max 0x7fffffffint map[202][202], dis[202], used[202], n = 0, m = 0, s =

2012-04-06 14:14:49 376

原创 HDOJ 3790 最短路径问题

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~code:#include #include #define Max 0xfffffffint n = 0, m = 0, s = 0, t = 0, map[1002][1002], cost[1002][1002], used[1002];int dis[1002], cost2[1002];void dijkstra(){

2012-04-04 18:06:20 530

原创 HDOJ 2544 最短路

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~code:#include #include #define Max 0xfffffffint n = 0, m = 0, map[102][102], dis[102], used[102];void dijskstra(){ int i = 0, j = 0, k = 0, min = 0; for(i = 2;

2012-04-04 12:21:25 379

原创 POJ 1182 食物链

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~思路:用并查集,用rank[x]表示该节点与父节点的关系,rank[x] = 0表示同类 , rank[x] = 1表示吃 ,rank[x] = 2表示被吃在网上看了半天的向量法,图都没有个,看都看不懂,还是画图就懂了(没图没真相ㄟ(▔,▔)ㄏ )

2012-04-04 10:27:40 445

原创 POJ 1988 Cube Stacking

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~code:#include int father[30001], num[30001], under[30001];//father存放根节点,num存放当前这个堆有多少个方块,under[i]存放第i个方块下有几个int find(int x){ int item = father[x];//记录上回合并时x所指向的根节点 if

2012-04-03 14:29:15 368

原创 POJ 3259 Wormholes (bellman_ford)

题目链接:~( ̄▽ ̄~)(~ ̄▽ ̄)~资料链接:\(▔▽▔)/ code:#include int n = 0, m = 0, w = 0, count = 0;typedef struct{ int u, v, weight;}node;node edge[6000];int bellman_ford(){ int i = 0, j = 0, d

2012-04-02 19:23:01 406

原创 POJ 1101 The Game (bfs)

题目连接: ~( ̄▽ ̄~)(~ ̄▽ ̄)~相邻的两个的segments为1,注意格式问题,wa了半天就在这2点上,郁闷code:#include #include int X1 = 0, Y1 = 0, X2 = 0, Y2 = 0, w = 0, h = 0, count2 = 0;char map[80][80];int dir[4][2] = {{-1, 0},

2012-04-02 16:24:33 475

原创 HDOJ 1042 N! (大数)

Problem DescriptionGiven an integer N(0 ≤ N ≤ 10000), your task is to calculate N! InputOne N in one line, process to the end of file. OutputFor each N, output N! in one line. Sample In

2012-04-02 12:39:41 487

原创 POJ 2488 A Knight's Journey (dfs)

DescriptionBackgroundThe knight is getting bored of seeing the same black and white squares again and again and has decided to make a journeyaround the world. Whenever a knight moves, it is two

2012-04-01 21:04:23 430

空空如也

空空如也

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

TA关注的人

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