上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 71 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4635tarjan缩点 统计缩点后每个结点的出度入度 将那个包含原来点数最少的 且出度或者入度为0的大节点看作一个整体内部连边n*(n-1)个 连全部的; 其它的点为一整体连全部的 再两者连一同向的边 保证它的出度或者入度依旧为0的情况下任意连 最后减去原来的边M 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 100010 8 #define M 100010... 阅读全文
posted @ 2013-08-02 10:46 _雨 阅读(290) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4642这题。。刚一看以为是什么高深的博弈 后来看过的人挺多 想是不是有什么规律 结果理解错题意了 以为随便圈一矩形改变就可以 然后想了一方法 跟QC说 然后就知道自己理解错题意了 必须圈到右下角 然后就乱了 后来QC说感觉只要右下角是1她就赢了 一想确实是这样啊 。。好简单 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int a[110][110]; 7 int main() 8 { 9 int i,j,t... 阅读全文
posted @ 2013-08-02 09:50 _雨 阅读(190) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4631比赛的时候搜到了最接近点对的求法 Nlog(N) 又估摸着依次插入求的话会TLE 想了想觉得可以先把最近的位置求出来 然后后面的直接不用求了 依次直到减完 又觉得可能会有变态的数据每次最近的都在最后面 没敢写。。后来 发现它出现在题解的方法三中。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 500005 8 #define LL long ... 阅读全文
posted @ 2013-07-31 19:23 _雨 阅读(187) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4630给的题解没看懂。。搜解题报告看 了N久 终于在cui大神的指点下 搞明白咋回事了将1-N中的每个数ai的倍数的位置p求出来 它们任意两个p组成的区间内约数至少为ai 在询问的区间L-R中如果存在这样的区间pi-pj那肯定存在相邻的 然后排好序 相邻的为一个区间l-r保存起来以r从小到大排序 将输入的询问区间进行离线处理 以R由小到大排序 对于每个区间插入r值比R小的区间 求值时以L为下界求到N 其实就是求到R 到R还快了500多ms。 1 #include 2 #include 3 #include . 阅读全文
posted @ 2013-07-31 19:18 _雨 阅读(184) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3321刚一看题以为要建一颗树 看了下讨论说dfs这里dfs遍历时设的标号很好 一个low一个high 包含了以这一节点为根节点的子树结点的所有标号 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 100010 8 #define lowbit(x) (x&(-x)) 9 struct node10 {11 int u,v,next;12 }ed[N<<1];13 int head[N],t, 阅读全文
posted @ 2013-07-29 19:41 _雨 阅读(190) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1195模版题 i写成k了 找了一个多小时没找出来。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 1050 8 #define lowbit(x) (x&(-x)) 9 int n,c[N][N];10 void add(int i,int j,int da)11 {12 int k;13 while(i>t>>n;43 memset(c,0,sizeof(c));44 w... 阅读全文
posted @ 2013-07-29 16:17 _雨 阅读(218) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4619二分图匹配 最小点覆盖 = 最大匹配 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int map[1010][1010]; 7 struct node 8 { 9 int x,y;10 }p[1010],q[1010];11 int n,m,vis[1010],link[1010];12 int judge(int i,int j)13 {14 if(p[i].x>n>>m)42 {4... 阅读全文
posted @ 2013-07-29 14:43 _雨 阅读(180) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2892记录每个区间端点的左连续及右连续 都是单点更新 用不着向下更新 还简单点找错找了N久 最后发现将s[w 2 #include 3 #include 4 #include 5 using namespace std; 6 #define N 50010 7 int lr[N>1;14 build(l,m,w>1;20 lr[w] = lr[w>1;36 if(p>1;49 if(p=p)58 return lr[w>n>>m)67 {68 build(1,n,1);... 阅读全文
posted @ 2013-07-29 14:33 _雨 阅读(252) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4614线段树的各种操作 写的有点乱 求插入位置是以区间K值的方法求出的 向下更新 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define N 50010 7 int s[N>1; 18 build(l,m,w>1; 49 if(p=r) 57 { 58 if(d) 59 s[w] = r-l+1; 60 else 61 ... 阅读全文
posted @ 2013-07-28 15:12 _雨 阅读(157) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2352二维逆序数 按一个数排序 转化为1维的 之前用树状数组写过 这次用线段树敲了下 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 32010 8 struct node 9 {10 int x, y;11 }st[N];12 int s[N>1;27 build(l,m,w>1;42 if(p=r)51 {52 return s[w];53 }54 ... 阅读全文
posted @ 2013-07-14 20:32 _雨 阅读(230) 评论(0) 推荐(0) 编辑
上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 71 下一页