题目大意:给定一张n(n <= 20)个点的带权无向图,点从0~n - 1标号,求起点0到终点n - 1的最短Hamilton路径。Hamilton路径的定义是从0到n - 1不重不漏地经过每个点恰好一次。 分析:这个题最朴素的想法就是枚举n个点的全排列,但是时间复杂度实在太高了。如果我们用二进制状 ...
分类:
其他好文 时间:
2020-01-28 15:45:48
阅读次数:
55
例一:对目录下的单词文件进行单词统计 /word/first.txt: /word/second.txt: /word/third.txt: 运行结果: import java.io.File; import java.io.PrintWriter; import scala.io.Source; ...
分类:
其他好文 时间:
2020-01-28 13:46:18
阅读次数:
76
这题真的是非常标准的模板题啊 看到连最少的边,第一时间会想到 $kruskal$ .这道题的难点其实就一个:你要注意到连边权最大的边使整个图联通 为什么:题意是第i个点想走到 $pos[i]$ ,也就是说点i和点 $pos[i]$ 必须要联通. 为什么想不到 $kruskal$ :因为 $krusk ...
分类:
其他好文 时间:
2020-01-28 12:21:13
阅读次数:
57
题解 排队模拟。需要注意的是,如果一个人在17:00及以后还没有开始服务,这种情况才输出“Sorry”。一个人在17:00之前已经开始了服务,就算结束服务在17:00之后,这样也是没问题的。 代码 #include<bits/stdc++.h> using namespace std; const ...
分类:
其他好文 时间:
2020-01-28 09:41:55
阅读次数:
66
给定一篇英语文章,要求统计出所有单词的个数,并按一定次序输出。思路是利用go语言的map类型,以每个单词作为关键字存储数量信息,代码实现如下: 1 package main 2 3 import ( 4 "fmt" 5 "sort" 6 ) 7 8 func wordCounterV1(str st ...
分类:
编程语言 时间:
2020-01-28 09:34:22
阅读次数:
80
题目如下: Given a m * n matrix mat of integers, sort it diagonally in ascending order from the top-left to the bottom-right then return the sorted array. ...
分类:
其他好文 时间:
2020-01-27 19:06:23
阅读次数:
72
C Fennec vs Monster 1. 链接 "C Fennec vs Monster" 2. 题意 消去k个最大值后,输出剩下的数组和。 3. 代码实现 ...
分类:
其他好文 时间:
2020-01-27 15:24:53
阅读次数:
74
类似于1213取水 可以把空投当作第0个城市 最后将0~n的所有城市跑最小生成树 1 /* 2 Written By StelaYuri 3 */ 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 struct r ...
分类:
其他好文 时间:
2020-01-27 09:43:38
阅读次数:
80
一、冒泡排序(Bubble Sort) 二、选择排序(Selection Sort) 三、插入排序(Insertion Sort) 九、桶排序(Bucket Sort) ...
分类:
编程语言 时间:
2020-01-26 22:13:19
阅读次数:
121
1 from heapq import heappush, heappop 2 class Solution: 3 def findTheCity(self, n: int, edges: 'List[List[int]]', distanceThreshold: int) -> int: 4 di ...
分类:
其他好文 时间:
2020-01-26 19:23:59
阅读次数:
87