上一页 1 ··· 3 4 5 6 7
摘要: 809773asia2562219EAccepted220 KB187 msC++1786 B2012-11-11 12:34:27 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <algorithm> 5 #include <iostream> 6 using namespace std; 7 #define MAXN 111111 8 int rank[222],father[222]; 9 int n,m,q;10 int max 阅读全文
posted @ 2012-11-11 12:40 TO_Asia 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 808075asia2562219BAccepted1172 KB31 msC++1299 B2012-11-10 20:19:31水爆了 Yes 一直写成 YES————!并查集~#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <iostream>using namespace std;#define MAXN 111111int deg[MAXN],tot,father[MAXN],totnum,tote;bool 阅读全文
posted @ 2012-11-10 20:25 TO_Asia 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 染色的树枝能否 相同颜色边连接成一个 欧拉回路#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <iostream>using namespace std;#define MAXN 5000050struct node{ int num; node *next[26];};node *root,tree[MAXN];int tot,totn=0;int deg[MAXN]; //度数int father[MAXN];voi 阅读全文
posted @ 2012-11-04 16:24 TO_Asia 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 796093asia2562219FAccepted524 KB15 msG++1525 B2012-11-04 12:37:34关键字树~ 简单题。。前序 中序 判同。#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <iostream>using namespace std;#define MAXN 11111struct Node{char data;Node* left;Node* right;};class BT 阅读全文
posted @ 2012-11-04 12:45 TO_Asia 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 被这道题 深深的伤害到了……http://poj.org/problem?id=174110985223asia25622191741Accepted1124K219MSC++2842B2012-11-03 23:59:11刚开始使用LCA解决问题 ,华丽丽超时,无脑百度了下。采用分治解决问题:题目的情况分两种:(1)两点间的路径经过根节点。(2)两点属于根节点的同一颗子树下。递归问题 ,所以只考虑第一种情况即可。dist[i]+dist[j]<=k 且 i和j 不在根节点的同一颗子树下;对dist排序 可以在线性时间内求出符合的对数。最最坑了我的是 分治时要找每颗树的重心。否则便是无尽 阅读全文
posted @ 2012-11-04 00:14 TO_Asia 阅读(968) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=167170676642012-11-02 20:02:57Accepted1671390MS3352K945 BC++TO_Asia字典树~~ 找手感中~~isnext=1 记录是否有下一个节点,判断前缀后出现的情况。isnext=2 表示是一个字串的最后一个字符,判断前缀先出现的情况。#include<iostream>#include<stdio.h>#include<string>using namespace std;class node{public: int i 阅读全文
posted @ 2012-11-02 20:08 TO_Asia 阅读(128) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=258670461182012-10-30 23:47:29Accepted258631MS3988K1931 BC++TO_Asia树和并查集~~求树中两个点的最近距离 转化成 求两个点的最近公共祖先(LCA)mindist(u,v)=dist(u)+dist(v)-2*dist(lca(u,v));向量存储树的邻接点View Code 1 #include <iostream> 2 #include <stdio.h> 3 #include <vector> 4 usin 阅读全文
posted @ 2012-10-30 23:53 TO_Asia 阅读(107) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7