MDeath-Kid

- M I T & Y
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  ACM-数据结构

线段树,树状数组,并查集
摘要:几句话道出map和hash_map的区别1. STL map is an associative array where keys are stored in sorted order using balanced trees. While hash_map is a hashed associated container, where keys are not stored in an ordered way. Key, value pair is stored using a hashed function. 2. Insertion and lookup takes Ologn time 阅读全文

posted @ 2011-11-20 19:54 MDeath-Kid 阅读(282) 评论(0) 推荐(0)

摘要:求相交的公路,对N排序,然后对M求逆序对,不过要求有相交的,必然要求在次城市后面,所以int sumge = i - (qur(s[tmp].y)) - ge;,这里修改了老多次,不过还好1Y了。3067#define lowbit(x) x & -xstruct sta{ int x,y;};sta s[MAXN];int n,m,k,maxx;int num[1005];int cmp(const void *a,const void *b){ struct sta *c = (sta *)a; struct sta *d = (sta *)b; if(c->x == d-& 阅读全文

posted @ 2011-07-21 16:50 MDeath-Kid 阅读(153) 评论(0) 推荐(0)

摘要:没见有人贴出来,一个1040ms的代码贴着了。大概思路就是:hash数组压缩+逆序数+树状数组求和+map-定位hash。测试数据也挺强。代码贴这:1443 1 /* 2 m332463970 1443 Accepted 5320 kb 1040 ms C++ 2656 B 2011-05-29 21:49:31 3 */#include<stdio.h> 4 //#include<conio.h> 5 #include<iostream> 6 #include<string.h> 7 #include<math.h> 8 #incl 阅读全文

posted @ 2011-05-29 22:03 MDeath-Kid 阅读(190) 评论(0) 推荐(0)

摘要:福州大学的1021.树状数组的应用。现在感觉博客园的代码贴纸不算好~~树状数组 1 #include<stdio.h> 2 #include<string.h> 3 #define MAXN 105 4 #define lowbit(x) ((x)&(-x)) 5 typedef int elem_t; 6 7 struct sum{ 8 elem_t a[MAXN],c[MAXN]; 9 int n;10 void init(int i){memset(a,0,sizeof(a));memset(c,0,sizeof(c));n=i;}11 void upda 阅读全文

posted @ 2011-05-26 20:55 MDeath-Kid 阅读(202) 评论(0) 推荐(0)