
搜索 广度优先搜索
文章平均质量分 84
Fsss_7
这个作者很懒,什么都没留下…
展开
-
2014上海全国邀请赛Maze
Maze Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 100000/100000 K (Java/Others) Total Submission(s): 517 Accepted Submission(s): 187 Problem Description This story happened原创 2015-01-23 00:40:11 · 662 阅读 · 0 评论 -
Codeforces Round #277 (Div. 2)D题
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated wit原创 2014-12-06 15:47:28 · 972 阅读 · 0 评论 -
BCBestCoder Round #74
链接:BestCoder Round #74 A:给定n,接下来是n-1个整数a[i]。a[i]表示在字符串s中从第i个开始的子串和从第i+1个开始的子串的最长公共前缀为a[i]。求字符串s有多少种情况。 分析:首先我们处理无解的情况,显然a[i]+i>n是无解的,并且相邻的a[i]如果非0则必然为a[i]-1==a[i+1]。然后就只要算方案数了。O(n) 代码: #include #i原创 2016-03-06 21:17:14 · 317 阅读 · 0 评论 -
Codeforces Round #361 (Div. 2)B. Mike and Shortcuts
链接:http://codeforces.com/contest/689/problem/B 题意:题面好长,但其实就是有n个城市,城市i到城市j需要的花费是|i-j|,并且每个城市有一条捷径直接从i花费1到a[i]。求从1开始到各个城市的最小花费。 分析:知道题意了其实就是一个每个点有3条边的图,直接从1点开始bfs就是了。 代码: #include #include #include原创 2016-07-07 20:54:03 · 529 阅读 · 0 评论