上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 19 下一页
摘要: 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1075大意:有外星人来了,但是我不懂外星文。然后我有一本字典,然我去翻译,字典由start开始有end结束的相当于map转换,然后是由由start开始有end结束的需要翻译的句子。代码#include <stdio.h>#include <string.h>#include <stdlib.h>#include <ctype.h>typedef struct node{ int flag; char ans[55]; struct node *next 阅读全文
posted @ 2012-08-13 20:41 某某。 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 这道题我用得静态树,发现静态树不如动态树啊,虽然时间快点,但是空间要求的也太离谱了~题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1247大意:让你输入几个单词,然后看看这有几个是可以有其他的任意两个单词或者一个单词两次,连接组成的,把他们输出就可以了代码View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 const int N=26; 5 const int maxn=1000000; 6 char s[5000 阅读全文
posted @ 2012-08-13 20:35 某某。 阅读(232) 评论(0) 推荐(0) 编辑
摘要: disjkstra 算法View Code #include <iostream>#include <stdio.h>#include <string.h>using namespace std;int map[205][205];void inint(int n){ int i,j; for(i = 0;i < n;i++) for(j = 0;j < n;j++) if(i != j) map[i][j] = 0x5fffffff; else map[i][j] = 0;}//初始化~void Dijkstra(int s,int t,int 阅读全文
posted @ 2012-08-12 20:27 某某。 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Building a Space Station题目连接:http://poj.org/problem?id=2031没有什么难点,唯一要注意的是重复路径和相交的情况,但是前一点用克鲁斯基本可以无视~今天涨姿势了~PKU上用G++输出时printf不能用lf得用f以前有个好习惯都用f。。。View Code加一个prim的写法View Code #include <stdio.h>#include <string.h>#include <math.h>#define maxn 1000000struct node{ double x,y,z,r;}degre 阅读全文
posted @ 2012-08-12 15:22 某某。 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1698大意:先输入一个t代表有t个案例,然后输入个数n代表一共有n个数,值为他们的编号1~n。然后输入q,代表q各更新,再输入a,b,c,代表把a_b的值全部改为c;然后求出所有的和。View Code 1 #include <stdio.h> 2 #define maxn 100007*4 3 struct node 4 { 5 int sum; 6 int lazy; 7 }tr[maxn]; 8 void pushup(int rt) 9 {10 tr[rt].sum... 阅读全文
posted @ 2012-08-12 15:11 某某。 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://poj.org/problem?id=3468题目大意:输入N,和Q,代表n个数字和q个操作,然后输入n个数字,然后再输入q个操作,Q代表求询问a,b编号之间的和(包含),C代表把a,b,之间的数都加上c。代码:View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 100000*4+50 4 struct node 5 { 6 __int64 num; 7 __int64 lazy;//lazy标记 8 }tr[maxn]; 9 __int64 count;10 v 阅读全文
posted @ 2012-08-12 15:06 某某。 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1166代码View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 50000*4+5 4 struct node { 5 int l,r,val; 6 }tr[maxn]; 7 void pushup(int rt) 8 { 9 tr[rt].val = tr[rt*2].val+tr[rt*2+1].val;10 return;11 }12 void build(int l,int r,int r. 阅读全文
posted @ 2012-08-10 21:53 某某。 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4217题意:就是让你输入一个N代表有1`n几个数,然后输入Q代表几次询问,每次询问输入一个K ,代表吧第K大的数删除。最后计算删除的数的大小~代码#include <stdio.h>#include <string.h>#define maxn 262145*4+5//一般开到最大的四倍大小就无压力~__int64 count,sub;struct node{ __int64 sum,count;}tr[maxn];void pushup(__int64 rt){ tr[rt]. 阅读全文
posted @ 2012-08-10 21:07 某某。 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 作者:Dong|可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明网址:http://dongxicheng.org/structure/segment-tree/1、概述线段树,也叫区间树,是一个完全二叉树,它在各个节点保存一条线段(即“子数组”),因而常用于解决数列维护问题,它基本能保证每个操作的复杂度为O(lgN)。2、线段树基本操作线段树的基本操作主要包括构造线段树,区间查询和区间修改。(1) 线段树构造首先介绍构造线段树的方法:让根节点表示区间[0,N-1],即所有N个数所组成的一个区间,然后,把区间分成两半,分别由左右子树表示。不难证明,这样的线段树的节点数只有2N 阅读全文
posted @ 2012-08-10 20:06 某某。 阅读(1236) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #define MAXV 100 3 #define INF 32767 4 //#include"graph.h" 5 6 void DispMat(MGraph g) 7 { 8 int i,j; 9 for(i=0;i<g.n;i++) 10 { 11 for(j=0;j<g.n;j++) 12 if(g.edges[i][j]==INF) 13 printf("%3s","∞"); 14 else 15 ... 阅读全文
posted @ 2012-08-07 15:48 某某。 阅读(216) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 19 下一页