题目大意:给定一个无向图,求出一条路径,使得边权和加上点权和最小,多组询问 n<=250 m<=10000 多组询问,数据范围这么小,很显然就是floyd了,但是这个点权着实让人讨厌哇。。。 我们重新回想一遍floyd算法的原理:i到j有两种可能:直接到和借助中间接口k,所以取一个min就行了 我们 ...
分类:
其他好文 时间:
2019-04-13 21:39:43
阅读次数:
140
<题目链接> 题目大意:给定一个无向图,该无向图不含自环,且无重边。现在要你将这个无向图定向,使得不存在任何一条路径长度大于等于2。然后根输入边的顺序,输出构造的有向图。如果构造的边与输入的方向一致,就输出1,方向不一致就输出0。 解题分析:因为定向后的图不能存在长度大于等于2的路径,所以我们直接对 ...
分类:
其他好文 时间:
2019-04-12 00:39:26
阅读次数:
160
``` class Solution { public: int uniquePathsWithObstacles(vector & obstacleGrid) { if (obstacleGrid.empty() || obstacleGrid[0].empty() || obstacleGrid ...
分类:
其他好文 时间:
2019-04-09 11:12:24
阅读次数:
138
``` class Solution { public: int uniquePaths(int m, int n) { vector dp(n, 1); for (int i = 1; i ...
分类:
其他好文 时间:
2019-04-09 11:03:45
阅读次数:
128
输入 java.util.Scanner java.lang.System java.io.Console 输出 输出 java.util.Scanner java.io.PrintWriter java.nio.file.Paths System.out.printf("%tc",new Date ...
分类:
编程语言 时间:
2019-04-07 13:00:36
阅读次数:
163
376. Binary Tree Path Sum 中文English Given a binary tree, find all paths that sum of the nodes in the path equals to a given number target. A valid pat ...
分类:
其他好文 时间:
2019-04-04 20:39:04
阅读次数:
211
Description: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or r ...
分类:
其他好文 时间:
2019-04-04 20:25:49
阅读次数:
147
Description: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or r ...
分类:
其他好文 时间:
2019-04-04 17:08:21
阅读次数:
174
F. Graph Without Long Directed Paths time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output F. ...
分类:
其他好文 时间:
2019-04-03 22:39:29
阅读次数:
154
F. Graph Without Long Directed Paths time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output F. ...
分类:
其他好文 时间:
2019-04-01 18:52:38
阅读次数:
253