好不容易又到周五了,周末终于可以休息休息了.写这一篇随笔只是心血来潮,下午问了一位朋友PAT考的如何,顺便看一下他考的试题,里面有最后一道题,是关于给出中序遍历和后序遍历然后求一个层次遍历.等等,我找一下链接出来...... 1127. ZigZagging on a Tree (30):https://www.patest.cn/contests/pat-a-practise/1127 突然想起以前学数据结构的时候如果给出一个中序遍历和一个后序遍历然后让你画出树的结构或求出先序遍历之类的题目,…
http://codeforces.com/contest/322/problem/E E. Ciel the Commander time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name sai…
十年河东,十年河西,莫欺骚年穷...打错一个字哈.~_~ 接着上一篇博客,上一篇博客是=使用数据库结合LINQ构造的,为了方便理解,本篇采用泛型分组进行构造. 有兴趣的小虎斑可以参考上一篇博客:如何构造分层次的 Json 数据 本篇很简单,直接上代码 using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using…
C - Upgrading Tree 我发现我构造题好弱啊啊啊. 很明显能想到先找到重心, 然后我们的目标就是把所有点接到重心的儿子上,让重心的儿子子树变成菊花图, 这个先把重心到儿子的边连到 i , 然后把 i 到 其 fa 的边连到重心的儿子上, 一直循环就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL p…
There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree. The tree has N forks which are connected by branches. Kaka numbers…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output This is an interactive problem. In the interaction section below you will find the information about flushing the output. The New Year tree of h…
def isValidTree(POTra): """ POTra :param list: :return: """ if not POTra: return True while len(POTra) > 1: index = [] n = len(POTra) for i in range(0, n-2): if POTra[i] != '#' and POTra[i+1] == '#' and POTra[i+2] == '#':…