题目来源:POJ 1679 The Unique MST
题意:判断最小生成树是否唯一 求出次小生成树比较
思路:慢一点的方法就是求出最小生成树 每次去掉最小生成树的一条边再求最小生成树 比较慢
更好的方法是 求出最小生成树后加上一条没有用到的边 然后必定出现一条回路 去掉回路上权值最大的边 做m-(n-1)次
求一次最小生成树 然后n^2的时间预处理最小生成树上两点之间最大的边权 最后...
分类:
其他好文 时间:
2014-06-01 13:53:03
阅读次数:
225
【题目】
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Note:
Given m, n satisfy the following condition:
1 ≤ m ≤ n ≤ length of list.
【题意】
...
分类:
其他好文 时间:
2014-06-01 15:08:34
阅读次数:
237
【题目】
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given "25525511135",
return ["255.255.11.135", "255.255.111.35"]. (Order does not matter)
【题意】
给定一个字符串,恢复并返回所有符合条件的IP串
【思路】...
分类:
其他好文 时间:
2014-06-01 13:01:56
阅读次数:
295
【题目】
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
Note: Recursive solution is trivial, could you do it iteratively?
confused what "{1,#,2...
分类:
其他好文 时间:
2014-06-01 13:01:23
阅读次数:
279
TOJ 614173971
HDU 宇智波佐助
POJ shiai
ZOJ henyumen
UVa henyumen
Light OJ HENYUMEN...
分类:
其他好文 时间:
2014-06-01 13:59:09
阅读次数:
210
【题目】
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 unique BST's.
1 3 3 2 1
\ / / / \ 3 2 1 ...
分类:
其他好文 时间:
2014-06-01 15:34:24
阅读次数:
231
【题目】
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3 3 2 1
\ / / / \ ...
分类:
其他好文 时间:
2014-06-01 15:33:45
阅读次数:
297
线性表
线性表分为链表和顺序表
链表按有无头结点分为有头结点链表和无头结点链表,按是否循环分为循环链表和非循环链表,按是否双向分为单向链表和双向链表
1。不带头结点非循环单链表
2.带头结点非循环单链表(头结点的值域是没有意义的)
3.不带头结点循环单链表
4.带头结点循环单链表(尾节点的下一个节点指向第一个值域有意义的节点)
5.不带头结点非循环双向...
分类:
其他好文 时间:
2014-06-01 13:00:46
阅读次数:
329
74LS183
搭的一个还有点意思的加法电路,串行进位的
2+6 == 8 大家都懂的哈哈...
分类:
其他好文 时间:
2014-06-01 14:56:02
阅读次数:
1741
前言:
以上涉及的各种背包问题都是要求在背包容量(费用)的限制下求可以取到的最大价值,但背包问题还有很多种灵活的问法,在这里值得提一下。但是我认为,只要深入理解了求背包问题最大价值的方法,即使问法变化了,也是不难想出算法的。例如,求解最多可以放多少件物品或者最多可以装满多少背包的空间。这都可以根据具体问题利用前面的方程求出所有状态的值(f数组)之后得到。还有,如果要求的是“总价值...
分类:
其他好文 时间:
2014-06-01 15:32:16
阅读次数:
278
2014 "嘉杰信息"杯 ACM/ICPC湖南程序设计邀请赛暨第六届湘潭程序设计比赛...
分类:
其他好文 时间:
2014-06-01 12:59:23
阅读次数:
444
Difference
between static and dynamic schedule in openMP in C...
分类:
其他好文 时间:
2014-06-01 13:05:15
阅读次数:
309
一、函数指针
//
// main.c
// L01Helloc
//
// Created by zj on 14-6-1.
// Copyright (c) 2014年 zj. All rights reserved.
//
#include
void sayHello(){
printf("Helloc C\n");
}
void sayHello1(int i){...
分类:
其他好文 时间:
2014-06-01 15:48:23
阅读次数:
261
二分图bipartite
使用BFS广度优先判断一个图是否是二分图。基本图操作。
参考
http://www.geeksforgeeks.org/bipartite-graph/
#pragma once
#include
#include
#include
using namespace std;
class CheckwhetheragivengraphisBipa...
分类:
其他好文 时间:
2014-06-01 15:03:24
阅读次数:
288
74LS85
demo:
1110>0111 就这样。。。。于是OAGTB引脚输出高电平点亮LED灯...
分类:
其他好文 时间:
2014-06-01 15:56:25
阅读次数:
426
问题:
对于给定序列1...n,permutations共有 n!个,那么任意给定k,返回第k个permutation。0
分析:
这个问题要是从最小开始直接到k,估计会超时,受10进制转换为二进制的启发,对于排列,比如 1,2,3 是第一个,那么3!= 6,所以第6个就是3,2,1。也就是说,从开始的最小的序列开始,到最大的序列,就是序列个数的阶乘数。那么在1,3 , 2的时候呢?调整一...
分类:
其他好文 时间:
2014-06-01 14:03:55
阅读次数:
257
1、在常规选项卡中“启动Firefox时”选择成“显示我的主页”2、在“主页”中填写“about:ntab”
分类:
其他好文 时间:
2014-06-01 11:29:01
阅读次数:
161