11 2019 档案
摘要:1、先序序列确定根节点 2、后序序列区分左右子树 #include<iostream> #include<algorithm> #include<vector> #include<math.h> #include<stdio.h> #include<string.h> #include<map> #
阅读全文
摘要:代码: #include<iostream> #include<algorithm> #include<vector> #include<math.h> #include<stdio.h> #include<string.h> #include<map> #include<queue> #inclu
阅读全文
摘要:已知前序遍历序列和中序遍历序列,可以唯一确定一棵二叉树。 已知后序遍历序列和中序遍历序列,可以唯一确定一棵二叉树。 但是已知前序遍历序列和后序遍历序列,是不能确定一棵二叉树的。 下面例子通过前序遍历和中序遍历确定唯一的一棵二叉树。 前序遍历:EACBDGF 中序遍历:ABCDEFG 1、首先根据前序
阅读全文
摘要:F: Horse Pro 豆豆也已经开始学着玩象棋了,现在豆豆已经搞清楚马的走法了,但是豆豆不能确定能否在 100 步以内从一个点到达另一个点(假设棋盘无限大)。 Input 第一行输入两个整数 x1,y1 表示当前马所在的位置。 第二行输入两个整数 x2,y2 表示豆豆想把马走在的位置。 −100
阅读全文
摘要:B: 最小代价 题解:先用最小生成树求联通所有点的最小代价ans 在求度为1的时候权值最大的点mx ans-mx就是答案 #include<iostream> #include<algorithm> #include<vector> #include<math.h> #define ll long
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/1168/C来源:牛客网 题目描述 已知了飞行器的起点和终点以及n个休息站的坐标,问起点到终点的最短路径是多少? 限制:飞行器不能长期飞行,必须中途在某结点下停下休息。(即连续飞行距离应不大于m) 欧涛师兄很想在师妹面前大
阅读全文
摘要:B: Prime Split 题解: 1、先判断两个素数w[i]、w[j]的和是否大于n-2,若小于则说明数字n不可能由三个素数组成(2是最小的素数) 2、再判断n-w[i]-w[j]是否是素数 3、保证w[i]、w[j]、n-w[i]-w[j]是递增的,避免重复计数 //注意laz[]要和线段树数
阅读全文
摘要:F: 操作数 题解:和刷气球那题一样,判断每个位置被更新的次数,如果是奇数输出1,偶数输出0 注意:用cin会超时 一、线段树 //注意laz[]要和线段树数组开一样大小 #include<iostream> #include<algorithm> #include<vector> #include
阅读全文
摘要:C. Swap Letters time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Monocarp has got two str
阅读全文
摘要:W - Prime Time 题意:用公式n*n+n+41,判断素数的百分比 #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string> #define ll long lon
阅读全文
摘要:A - Bi-shoe and Phi-shoe Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He n
阅读全文
摘要:D. Treasure Island time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output All of us love treasur
阅读全文
摘要:F. Fixing Banners time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Harbin, whose name was
阅读全文
摘要:一、满二叉树 一棵二叉树的结点要么是叶子结点,要么它有两个子结点(如果一个二叉树的层数为K,且结点总数是(2^k) -1,则它就是满二叉树。) 二、完全二叉树 若设二叉树的深度为k,除第 k 层外,其它各层 (1~k-1) 的结点数都达到最大个数,第k 层所有的结点都连续集中在最左边,这就是完全二叉
阅读全文