图论
文章平均质量分 68
CharlieBrownn
八重樱花繁且枝盛,君需记累瓣必偿情。
展开
-
ACM-ICPC 2018 南京赛区网络预赛 L-Magical Girl Haze
#include<iostream>#include<stdio.h>#include<cstring>#include<string>#include<vector>#include<math.h>#include<queue>#include<set>#include原创 2018-10-07 20:50:49 · 147 阅读 · 0 评论 -
欧拉回路 和 哈密顿回路
图是连通图哈密顿回路:经过每个点一次并且回到起点欧拉回路:经过每一条边并回到起点通路:在无向图中由点边交替组成的序列就是通路(如果这个图是简单的,那么也可以使用点的序列来表示),如果首尾的点相同,则称为一条回路无向图的连通性:无向图中任意一对点之间均有通路欧拉通路:从某个顶点出发,将所有的边遍历一遍并且仅经过一遍的通路序列称为欧拉通路,连通的多重图有欧拉回路而无欧拉回路当且仅当...原创 2018-12-08 15:45:21 · 4300 阅读 · 0 评论 -
Is It A Red-Black Tree
判断一颗树是否是红黑树-_-b首先,红黑树是一棵平衡二叉树,平衡二叉树又是一棵二叉搜索树。简单的说就是左子树中,子节点比父节点小,右子树中,子节点比父节点大。根节点一定是黑节点。先按先序遍历用编号建树,然后判断,子节点与父节点的大小关系、用编号DFS左右子树的黑节点个数是否一样。There is a kind of balanced binary search tree named re...原创 2018-12-04 17:52:24 · 477 阅读 · 0 评论 -
Vertex Cover(图的覆盖
给出一个点集,判断是否是图的覆盖。就是与这些点相连的边是否覆盖了整张图。给每条边编号,Push进相连的点里,按点集标记判断就看以了。A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now ...原创 2018-12-04 16:54:25 · 759 阅读 · 0 评论 -
Postorder Traversal(给出先序遍历和中序遍历求后序遍历)
不用建树首先,先序遍历第一个一定是根节点。现在暂时叫它NOW(在先序遍历里的位置)(即当前节点)然后在中序遍历里找到NOW的位置,假设位置下标是POS(中序遍历),那么左边的就是左子树(L ~ POS-1),右边的就是右子树(POS+1 ~ R)。(都是指中序遍历)一开始的范围是0~N-1(L ~ R)遍历左子树:根节点下标是NOW+1(先序遍历),左边界依然是 L , 右边界是POS ...原创 2018-12-02 00:43:54 · 1728 阅读 · 0 评论 -
ZigZagging on a Tree(由中序遍历和后序遍历求前序遍历
基本上就是由中序遍历和后序遍历求前序遍历将前序遍历按层数存,输出的时候根据层数的奇偶按顺序/逆序输出就可以了Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder a...原创 2018-12-04 16:22:10 · 846 阅读 · 0 评论 -
Eulerian Path
**通路:**在无向图中由点边交替组成的序列就是通路(如果这个图是简单的,那么也可以使用点的序列来表示),如果首尾的点相同,则称为一条回路**无向图的连通性:**无向图中任意一对点之间均有通路**欧拉通路:**从某个顶点出发,将所有的边遍历一遍并且仅经过一遍的通路序列称为欧拉通路,连通的多重图有欧拉回路而无欧拉回路当且仅当它恰有两个奇数度顶点这里说明了欧拉通路的条件:图是连通的,没有孤立...原创 2018-12-04 16:16:46 · 381 阅读 · 0 评论 -
Gasoline Gym - 101908G(网络流+二分答案)
After the end of the truck drivers’ strike, you and the rest of Nlogônia logistics specialists now have the task of planning the refueling of the gas stations in the city. For this, we collected infor...原创 2018-10-19 20:31:18 · 394 阅读 · 0 评论 -
Pizza Cutter Gym - 101908C (树状数组求逆序数+离散化)
Grandpa Giuseppe won a professional pizza cutter, the kind of type reel and, to celebrate, baked a rectangle pizza to his grandchildren! He always sliced his pizzas into pieces by making cuts over con...原创 2018-10-19 20:28:35 · 378 阅读 · 0 评论 -
Is It a Complete AVL Tree
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is...原创 2018-12-05 22:47:27 · 148 阅读 · 0 评论