LouZhang

导航

2012年8月1日

离散化 + unique + lower_bound的学习,hdu4325

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4325这题看了数据就会发现,数据都很小的。。。。所以直接暴力能过当然开始我用的线段树后来想到,既然离散化了,那来暴力试试吧所以当作学习吧,同时学习了unique这个函数了用unique之前最好先排序一开始我以为unique是去除所有相同元素,哪想到其实也是个排序罢了#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 100000 + 10;int a 阅读全文

posted @ 2012-08-01 22:41 louzhang_swk 阅读(551) 评论(0) 推荐(0) 编辑

最近整理的模板

摘要: dfs //http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3631 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[40]; int b[40]; int ans; int n, m; /* void dfs(int k, int sum) { if(ans == m)return; if(k == 0){ ans = max(sum, ans); ... 阅读全文

posted @ 2012-08-01 19:11 louzhang_swk 阅读(319) 评论(0) 推荐(0) 编辑

AOE网络,最长路关键路径的学习

摘要: 我只想说,被坑了总以为这本书上没有错。。。却出现了两个错误书上用的指针邻接表,我想学下数组模拟,然后就全改了一个点表示一个事件,一条边表示该活动的时间那么对于每个事件和每个活动都有最早可能开始时间和最迟允许开始时间了具体思路也不想写了,本想画个图来写篇博客。。浪费时间啊。。时间宝贵啊。。贴代码吧。。#include<cstdio>#include<cstring>const int maxn = 10000;//顶点个数最大值const int maxm = 10000;//边数最大值struct node{ int to, w, id;//边的另一个顶点,持续时间,活 阅读全文

posted @ 2012-08-01 11:43 louzhang_swk 阅读(1493) 评论(1) 推荐(0) 编辑

单调队列的学习

摘要: 前天CUG比赛的D题,也就是POJ3250题http://poj.org/problem?id=3250正好拿来学习了下单调队列了#include<cstdio>#include<cstring>const int maxn = 100000 + 10;int maxq[maxn];int ind[maxn];int q[maxn];int n;int a[maxn];long long ans = 0;void calc(){ int head = 1, tail = 0; for(int i = 1; i <= n; i ++){ while(head < 阅读全文

posted @ 2012-08-01 10:16 louzhang_swk 阅读(184) 评论(0) 推荐(0) 编辑