Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen... ...
分类:
其他好文 时间:
2018-11-06 11:02:41
阅读次数:
112
题目大意: 找基环树直径 (这个题输入给出的是内向基环树(虽然是无向边)) 存在两种情况: 1.直径在树上。 2.直径从树里走到环上,再走进另外一个树里。 首先dfs找到环。 第一种直接树形dp。dp[i]i往下最长路径。还能用来求第二种情况。 第二种,找到环之后,断环成链,复制一倍。求的是,选择距 ...
分类:
其他好文 时间:
2018-11-04 12:53:20
阅读次数:
219
题目传送门 传送门I 传送门II 传送门III 题目大意 (八数码问题的树上版本)。 已经存在解的时候直接输出最少的移动步数。 否则允许加入一条边,要求输出边的端点以及最少的移动步数。 仍然无解输出-1. 题目传送门 传送门I 传送门II 传送门III 题目大意 (八数码问题的树上版本)。 已经存在 ...
分类:
其他好文 时间:
2018-10-31 23:30:44
阅读次数:
696
You are given a map in form of a two dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/ve ...
分类:
其他好文 时间:
2018-10-30 13:15:38
阅读次数:
129
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo ...
分类:
其他好文 时间:
2018-10-21 16:56:24
阅读次数:
449
题面 好像没啥可说的,就当练码力了...... 先用BFS跑出岛屿,然后跑最短路求岛屿间的距离,最后状压DP得出答案 注意细节,码码码2333 1 #include<set> 2 #include<queue> 3 #include<cstdio> 4 #include<cstring> 5 #in ...
分类:
其他好文 时间:
2018-10-12 21:10:22
阅读次数:
148
1 int x[] = {1,-1,0,0}; 2 int y[] = {0,0,1,-1}; 3 4 class Solution 5 { 6 private: 7 int acreList[1500]; 8 int acreListEnd; 9 int Maxresult; 10 ... ...
分类:
其他好文 时间:
2018-10-11 12:59:42
阅读次数:
326
HDU 4280:http://acm.hdu.edu.cn/showproblem.php?pid=4280 题意: 比较裸的最大流题目,就是这是个无向图,并且比较卡时间。 思路: 是这样的,由于是无向图,所以addedge 的反边容量直接设为原始流量。然后还可以优化搜索的方向,bfs可以从t到s ...
分类:
其他好文 时间:
2018-10-10 01:01:04
阅读次数:
189
2018-10-06 19:44:18 问题描述: 问题求解: 经典的求连通块问题的扩展,问题规模不大,可以暴力求解。 解法一、Brute Force O(n^4) 解法二、 为每个连通块做上标记,并得到每个连通块的面积,之后再对0进行遍历,依次寻找其四个相邻的边的area,将他们加起来再从中取ma ...
分类:
其他好文 时间:
2018-10-06 21:29:18
阅读次数:
192
Description 你将要游览一个有N个岛屿的公园。从每一个岛i出发,只建造一座桥。桥的长度以Li表示。公园内总共有N座桥。尽管每座桥由一个岛连到另一个岛,但每座桥均可以双向行走。同时,每一对这样的岛屿,都有一艘专用的往来两岛之间的渡船。 相对于乘船而言,你更喜欢步行。你希望所经过的桥的总长度尽 ...
分类:
其他好文 时间:
2018-10-06 11:54:59
阅读次数:
226