码迷,mamicode.com
首页 >  
搜索关键字:binary tree upside d    ( 23249个结果)
HDU 1325 POJ 1308 Is It A Tree? (并查集)
这道题就是裸并查集,关键在于对不是树几种的判断 1. 空树是树 2. 森林不是树 3. 无环 或者从入度来看:1,无环;2,除了根,所有的入度为1,根入度为0;3,这个结构只有一个根,不然是森林了。 这道题本来暑假做的POJ 1308 但是HDU没有过。在于空树没有考虑。 用并查集判断有多少个森林注意编号是随机的,不是次序.... /* input: 0 0 1 1 0 0...
分类:其他好文   时间:2014-11-04 22:53:53    阅读次数:325
HDU4757 Tree(可持久化Trie)
写过可持久化线段树,但是从来没写过可持久化的Trie,今天补一补。题目就是典型的给你一个数x,和一个数集,问x和里面的某个数xor起来的最大值是多少。最原始的是数集是固定的,只需要对数集按照高到低位去建Trie,然后贪心匹配就可以了。这里则是对树上路径的操作,其实也是一样的,对每个节点x维护root...
分类:其他好文   时间:2014-11-04 22:36:12    阅读次数:332
[LeetCode] Add Binary
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100"思路:时间复杂度O(n), 空间复杂度O(1) 1 class Solution { 2 pub...
分类:其他好文   时间:2014-11-04 22:35:25    阅读次数:246
POJ 3237 Tree 树链剖分
单点替换,区间取相反数,区间求最大值,其实线段树里面只要保存最小值和最大值就可以了,取反之后最小值变成最大值最大值变成最小值。#include #include #include #include #include #include #include #include #include #inclu...
分类:其他好文   时间:2014-11-04 22:35:00    阅读次数:202
10.10 review
Problem 1. TreeInput file: tree.inOutput file: tree.outTime limit: 1 second给出 N 个点的树和 K,问能否把树划分成 N /K 个连通块,且每个连通块的点数都是 K。Input第 1 行,1 个整数 T ,表示数据组数。接下...
分类:其他好文   时间:2014-11-04 22:29:10    阅读次数:291
Jtree (节点的渲染+资源管理器)
我们的还是自定义的Jtree的类: package jtree.customNode; import java.io.File; import javax.swing.JTree; import javax.swing.tree.DefaultTreeModel; import util.Image...
分类:其他好文   时间:2014-11-04 22:21:29    阅读次数:310
POJ 3358 Period of an Infinite Binary Expansion( 数论好题 + 欧拉定理 + 欧拉函数 )
POJ 3358 Period of an Infinite Binary Expansion( 数论好题 + 欧拉定理 + 欧拉函数 )#include #include #include #include using namespace std;typedef long long LL;LL f...
分类:其他好文   时间:2014-11-04 21:07:26    阅读次数:167
Leetcode | Gray code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total numb...
分类:其他好文   时间:2014-11-04 18:48:23    阅读次数:187
LeetCode:Symmetric Tree
题目描述: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / 2 2 / \ / 3 4 4 3 ...
分类:其他好文   时间:2014-11-04 17:24:06    阅读次数:132
HDU 3804 Query on a tree (树链剖分)
树链剖分...
分类:其他好文   时间:2014-11-04 15:07:18    阅读次数:182
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!