上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 25 下一页

2011年7月23日

POJ 2481 cows 树状数组

摘要: 题意很简单,需要注意的一点是当两头牛的range完全相同的时候后面的牛的Strongnumber==前面牛的Strongnumber,效率不是很高,2200+ms#include<stdio.h>#include<algorithm>#include<string.h>#include <iostream>using namespace std;typedef struct{ int x; int y; int index;}cow;cow cows[100010];int N;int tree[100010];int ans[100010];b 阅读全文

posted @ 2011-07-23 09:46 lonelycatcher 阅读(347) 评论(0) 推荐(0) 编辑

STL sort 和 qsort 的用法

摘要: STL 中 sort 函数用法简介 转自http://blog.csdn.net/rattles/article/details/5510919 做 ACM 题的时候,排序是一种经常要用到的操作。如果每次都自己写个冒泡之类的 O(n^2) 排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错。 STL 里面有个 sort 函数,可以直接对数组排序,复杂度为 n*log2(n) 。使用这个函数,需要包含头文件。 这个函数可以传两个参数或三个参数。第一个参数是要排序的区间首地址,第二个参数是区间尾地址的下一地址。也就是说,排序的区间是 [a,b) 。简单来说,有一个数组 int a[10 阅读全文

posted @ 2011-07-23 09:37 lonelycatcher 阅读(698) 评论(0) 推荐(1) 编辑

2011年7月22日

POJ 2352 starts 树状数组

摘要: #include <iostream>#include<stdio.h>#include<string.h>using namespace std;int N;int x,y;int tree[33000];int level[16000];int lowbit(int t){return t&(-t);}void update(int index){ while(index<33000) { tree[index]++; index+=lowbit(index); }}int getSum(int index){ int sum=0; whi 阅读全文

posted @ 2011-07-22 14:35 lonelycatcher 阅读(170) 评论(0) 推荐(0) 编辑

2011年7月21日

ACM必须要学会的知识点

摘要: 1) 数据结构(一): 线段树,树状数组,二维线段树2) 动态规划:状态压缩,树形动归,平行四边形法则3) 数据结构(二): DFA, Trie树,Trie图等4) 搜索:深搜,广搜,剪枝,IDA*算法5) 若干图论问题:强连通分量、桥和割点等6) 计算几何:线与线求交,线与面求交,求凸包,半平面求交等7) 网络流算法:基本的网络流算法,Dinic算法,带上下界的网络流,最小费用流8) 数学题:组合数学,数论等 阅读全文

posted @ 2011-07-21 15:24 lonelycatcher 阅读(881) 评论(0) 推荐(0) 编辑

HDU 1015 Safecracker

摘要: 与其说这是一道搜索题,倒不如说是一道枚举题更加合适,反正就是纯暴力。。。。注意读懂题意#include<iostream>#include<stdio.h>#include<string.h>#include<math.h>#include<string>#include<algorithm>using namespace std;char s[12];int cmp(const void*a ,const void*b){ return *(int*)b-*(int*)a;}__int64 target;int main 阅读全文

posted @ 2011-07-21 10:59 lonelycatcher 阅读(208) 评论(0) 推荐(0) 编辑

上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 25 下一页

导航