LeeBlog

导航

随笔分类 -  排序

HDU 2020 绝对值排序 堆优化
摘要:用二叉排序树写一个#include<stdio.h>typedef struct Node{ int data; struct Node *lc,*rc;}node,*Link;int n,f;inline int fab( int a ){ return a > 0 ? a : -a;}void insert( Link *L,int x ){ if( *L ) { if( fab( x ) > fab( ( *L ) -> data ) ) insert( &( *L ) -> lc,x ); else insert( &( *L ) - 阅读全文

posted @ 2011-06-13 16:33 LeeBlog 阅读(621) 评论(0) 推荐(0)

HDU 1280 堆排
摘要:堆排第一道。。 开始一直wa。。 最后发现up和down都没递归#include<stdio.h>int num[30005],e[9000000],n,m,c;inline void swap( int i,int j ){ e[i] ^= e[j] ^= e[i] ^= e[j];}void up( int c ){ if( c > 1 ) if( e[c] > e[c/2] ) swap( c,c/2 ),up( c / 2 );}void insert( int x ){ e[++c] = x; up( c );}inline void down( int q 阅读全文

posted @ 2011-06-11 10:11 LeeBlog 阅读(527) 评论(0) 推荐(0)

hdu 1509
摘要:#include<stdio.h>#include<string.h>struct E{ char name[1000]; char less[1000]; int d; int num; }e[60024];int c = 0,max = 0,count = 0;void swap( int x,int y ){ struct E t; t = e[ x ]; e[ x ] = e[ y ]; e[ y ] = t; }int cmp( int x,int y ){ if( e[ x ].d == e[ y ].d ) if( e[x].num < e[y].n 阅读全文

posted @ 2011-03-01 17:23 LeeBlog 阅读(382) 评论(0) 推荐(0)