基环树 找环,环外处理,环上处理 #include<bits/stdc++.h> #define re return #define inc(i,l,r) for(int i=l;i<=r;++i) using namespace std; template<typename T>inline vo ...
分类:
其他好文 时间:
2019-10-23 12:00:57
阅读次数:
77
In a 2D grid of s and s, we change at most one to a . After, what is the size of the largest island??(An island is a 4 directionally connected group o ...
分类:
其他好文 时间:
2019-10-14 01:24:21
阅读次数:
105
题目链接:传送门 思路: 仔细观察可以发现,答案最多就是2,只要把(2,1)和(1,2)堵住就可以了。 答案是0的情况就是初始状态下,(1,1)就已经不可达(n,m)了,很好判断。 所以重点就是区分答案为1和答案为2的情况。 如果答案为1的话,就说明从(1,1)到(n,m)的所有路径都经过同一个点( ...
分类:
其他好文 时间:
2019-10-08 12:08:17
阅读次数:
87
On a mysterious island there are creatures known as Quxes which come in three colors: red, green, and blue. One power of the Qux is that if two of the ...
分类:
其他好文 时间:
2019-09-14 10:30:32
阅读次数:
110
题目大意 给你一个n m 的棋盘 有的地方不能过 问题最少需要堵多少次 才能让(1,1)到(n,m)没有路径通过 解法: 打表发现 对角线最后剩下的通路最少 即为答案 画图可知$ 2 2$的子矩形内 右对角线被填满时左对角线都不能到达 递推判断即可 细节蛮多的 code: include inclu ...
分类:
其他好文 时间:
2019-09-08 00:13:05
阅读次数:
72
其实是一道水题,很显然答案一定是0、1、2中的某一个数 那么直接上dfs搜一遍,标记走过的点,如果这一次dfs不能到达终点,那么答案为0 否则再dfs一遍,dfs时不走标记过的点,如果这一次不能到达终点,那么答案为1 否则答案为2 ...
分类:
其他好文 时间:
2019-09-05 13:57:37
阅读次数:
72
原文引用https://www.dazhuanlan.com/2019/08/26/5d62fb8538067/ Island Perimeter 原题: You are given a map in form of a two-dimensional integer grid where 1 re ...
分类:
其他好文 时间:
2019-08-26 09:37:56
阅读次数:
95
一、图的基础知识 1.连通图与非连通图 连通图(Connected Graphs)指图内任意两个节点间,总能找到一条路径连接它们,否则,为非连通图(Disconnected Graphs)。也就是说,如果图中包含岛(Island),则是非连通图。如果岛内的节点都是连通的,这些岛就被成为一个部件(Co ...
分类:
编程语言 时间:
2019-08-15 19:14:34
阅读次数:
111
bzoj luogu 题意可能会很绕 一句话:基环树的直径。 求直径: 对于环上每一个点记录其向它的子树最长路径为$dp_x$ 之后记录环上边长前缀和$ns_i$ dp值为$max_{i,j}dp[i]+sum[i]+dp[j]-sum[j]$ $dp[j]-sum[j]$提出来进单调队列。 O(n ...
分类:
其他好文 时间:
2019-08-10 21:03:02
阅读次数:
129
链接: https://vjudge.net/problem/HDU 4280 题意: In the vast waters far far away, there are many islands. People are living on the islands, and all the tra ...
分类:
其他好文 时间:
2019-08-09 20:04:07
阅读次数:
118