基础算法
文章平均质量分 82
da_kao_la
这个作者很懒,什么都没留下…
展开
-
HDU 1541 Stars(树状数组)
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1541问题描述StarsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12581 Accepted Submission(...原创 2018-08-08 21:18:16 · 223 阅读 · 0 评论 -
2018年清华软院保研夏令营第4题:建高铁(堆优化双向Dijkstra)
题目编号为1到N的N个城市间有M条铁路,通过每条铁路花费时间T_i,为了减少从城市1到N的时间,现在决定将其中一条铁路改建成高铁,改建后通过该条铁路的时间将减半(向下取整数),求改建哪条铁路可以使得改建后从城市1到城市N的时间最短 输入:第一行N和M 接下来M行,每行A_i, B_i, T_i分别是第i条铁路的起点和终点,以及时间 输出:改建的铁路编号以及改建后从1到N的时间 注意:铁...原创 2018-09-06 21:47:12 · 1056 阅读 · 2 评论 -
POJ 3468 A Simple Problem with Integers(线段树区间更新)
题目来源:http://poj.org/problem?id=3468问题描述A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 142569 Accepted: 44...原创 2018-09-10 10:38:05 · 192 阅读 · 0 评论 -
POJ 3080 Blue Jeans(动态规划)
题目来源:http://poj.org/problem?id=3080问题描述Blue Jeans Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21252 Accepted: 9426 Description...原创 2018-09-10 13:51:59 · 210 阅读 · 0 评论 -
POJ 1458 Common Subsequence(最大公共子列)
题目来源:http://poj.org/problem?id=1458问题描述Common Subsequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 61994 Accepted: 25986 Desc...原创 2018-09-10 16:22:01 · 154 阅读 · 0 评论 -
POJ 2965 The Pilots Brothers' refrigerator(状态空间搜索 + 位运算)
题目来源:http://poj.org/problem?id=2965问题描述 The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 29...原创 2018-09-07 15:35:41 · 195 阅读 · 0 评论 -
POJ 3041 Asteroids(匈牙利算法)
题目来源:http://poj.org/problem?id=3041问题描述 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26626 ...原创 2018-09-14 11:31:04 · 282 阅读 · 0 评论 -
LeetCode周赛#105 Q3 Complete Binary Tree Inserter (二叉树)
题目来源:https://leetcode.com/contest/weekly-contest-105/problems/complete-binary-tree-inserter/问题描述919. Complete Binary Tree InserterA complete binary tree is a binary tree in which every level, ex...原创 2018-10-11 09:45:35 · 154 阅读 · 0 评论 -
2018年清华软院保研夏令营第3题:质因子(单调队列)
题目给定N个质数,构成集合S,设集合T为由质因子全部在S中的整数构成的集合,求T中第k小的数,其中1<=N<=100,1<=k<=1e5,输出保证在int的范围之内 输入:第一行 N,k 第二行 N个质数--------------------------------------------------------------------------------...原创 2018-09-06 17:11:25 · 1058 阅读 · 0 评论 -
NYOJ 26 孪生素数问题(素数筛法)
题目来源:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=26问题描述孪生素数问题时间限制:3000 ms | 内存限制:65535 KB难度:3描述写一个程序,找出给出素数范围内的所有孪生素数的组数。一般来说,孪生素数就是指两个素数距离为2,近的不能再近的相邻素数。有些童鞋一看到题就开始写程序,不仔细看题,咱们为...原创 2018-09-09 17:21:39 · 1085 阅读 · 0 评论 -
POJ 1094 Sorting It All Out(入度法求拓扑排序,成环判断)
题目来源:http://poj.org/problem?id=1094问题描述Sorting It All Out Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 39161 Accepted: 13808 Desc...原创 2018-09-09 09:13:08 · 392 阅读 · 0 评论 -
HDU 1874 畅通工程续(SPFA最短路)
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1874问题描述畅通工程续Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 70085 Accepted Submission(...原创 2018-08-16 17:58:38 · 182 阅读 · 0 评论 -
百练 大整数的加减乘除(C++高精度)
题目来源:http://cxsjsxmooc.openjudge.cn/test/D/D:大整数的加减乘除总时间限制: 1000ms 内存限制: 65536kB描述给出两个正整数以及四则运算操作符(+ - * /),求运算结果。输入第一行:正整数a,长度不超过100第二行:四则运算符o,o是“+”,“-”,“*”,“/”中的某一个第三行:正整数b,长度不超过100保证输...原创 2018-09-01 14:38:04 · 2302 阅读 · 0 评论 -
POJ 3461 Oulipo(字符串匹配,KMP算法)
题目来源:http://poj.org/problem?id=3461Oulipo Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 49522 Accepted: 19665 DescriptionThe Frenc...原创 2018-09-02 11:28:24 · 324 阅读 · 0 评论 -
POJ 2513 Colored Sticks(字典树、并查集、连通性)
题目来源:http://poj.org/problem?id=2513问题描述Colored Sticks Time Limit: 5000MS Memory Limit: 128000K Total Submissions: 39772 Accepted: 10359 Descrip...原创 2018-09-11 15:44:43 · 189 阅读 · 0 评论 -
POJ 1182 食物链(并查集)
题目来源:http://poj.org/problem?id=1182问题描述食物链 Time Limit: 1000MS Memory Limit: 10000K Total Submissions:92616 Accepted: 27955 Description动物王国中有三...原创 2018-09-08 14:16:48 · 157 阅读 · 0 评论 -
POJ 2367 Genealogical tree(拓扑排序DFS解法)
题目来源:http://poj.org/problem?id=2367问题描述Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7878 Accepted: 5122 ...原创 2018-09-08 16:51:11 · 178 阅读 · 0 评论 -
POJ 1837 Balance(0-1背包)
题目来源:http://poj.org/problem?id=1837问题描述 Balance Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16582 ...原创 2018-09-11 19:24:23 · 150 阅读 · 0 评论 -
HDU 1846 Brave Game (Bash博弈)
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1846问题描述Brave GameTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15478 Accepted Submis...原创 2018-10-05 16:17:19 · 180 阅读 · 0 评论 -
HDU 2516 取石子游戏(Fibonacci博弈)
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=2516问题描述取石子游戏Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8263 Accepted Submission(s...原创 2018-10-05 17:55:07 · 239 阅读 · 0 评论 -
LeetCode 126. Word Ladder II(bfs回溯路径)
题目来源:https://leetcode.com/problems/word-ladder-ii/问题描述126.Word Ladder IIHardGiven two words (beginWordandendWord), and a dictionary's word list, find all shortest transformation sequence(s)...原创 2019-06-16 01:00:46 · 564 阅读 · 0 评论 -
144. Binary Tree Preorder Traversal(递归的栈模拟)
CandyHardThere are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at ...原创 2019-07-08 20:35:34 · 119 阅读 · 0 评论 -
LeetCode 146. LRU Cache
LRU CacheMediumDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) ...原创 2019-07-17 22:19:15 · 165 阅读 · 0 评论 -
Java双基准快速排序算法java.util.DualPivotQuicksort源码阅读
Java双基准快速排序算法源码阅读jdk版本:jdk1.8.0_191Java数组和List对象的排序方法分别是Arrays.sort(T[] a)和Collections.sort(List<T> list),分别位于java.util.Arrays和java.util.Collections类中. 由于List底层采用数组实现,因此Collections.sort方法也是通过调...原创 2019-08-04 09:44:21 · 751 阅读 · 0 评论 -
LeetCode 214. Shortest Palindrome(Manacher算法)
题目来源:https://leetcode.com/problems/shortest-palindrome/问题描述214.Shortest PalindromeHardGiven a strings, you are allowed to convert it to a palindrome by adding characters in front of it. Find...原创 2019-08-13 13:49:14 · 246 阅读 · 0 评论 -
LeetCode 210. Course Schedule II(拓扑排序)
LeetCode 210. Course Schedule IIMediumThere are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take...原创 2019-08-20 19:24:34 · 224 阅读 · 0 评论 -
LeetCode 208. Implement Trie (Prefix Tree)
题目来源:https://leetcode.com/problems/implement-trie-prefix-tree/问题描述208.Implement Trie (Prefix Tree)MediumImplement a trie withinsert,search, andstartsWithmethods.Example:Trie trie = n...原创 2019-08-12 23:37:55 · 154 阅读 · 0 评论 -
LeetCode 84. Largest Rectangle in Histogram(单调栈)
题目来源:https://leetcode.com/problems/largest-rectangle-in-histogram/问题描述84.Largest Rectangle in HistogramHardGivennnon-negative integers representing the histogram's bar height where the widt...原创 2019-05-09 21:21:11 · 191 阅读 · 0 评论 -
LeetCode 148. Sort List(链表归并排序)
题目来源:https://leetcode.com/problems/sort-list/问题描述148.Sort ListMediumSort a linked list inO(nlogn) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1-&...原创 2019-04-18 19:25:17 · 207 阅读 · 0 评论 -
LeetCode 65. Valid Number(有限状态自动机)
题目来源:https://leetcode.com/problems/valid-number/问题描述65.Valid NumberHardValidate if a given string can be interpreted asa decimal number.Some examples:"0"=>true" 0.1 "=>true"abc"...原创 2019-04-23 12:24:41 · 765 阅读 · 0 评论 -
HDU 1527 取石子游戏(Wythoff博弈)
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1527问题描述取石子游戏Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9875 Accepted Submission(s...原创 2018-10-05 21:25:38 · 187 阅读 · 0 评论 -
LeetCode周赛#104 Q4 Cat and Mouse (图论+博弈论,记忆化搜索)
题目来源:https://leetcode.com/contest/weekly-contest-104/problems/cat-and-mouse/问题描述913. Cat and MouseA game on anundirectedgraph is played by two players, Mouse and Cat, who alternate turns.The...原创 2018-10-06 09:54:29 · 1234 阅读 · 9 评论 -
HDU 1850 Being a Good Boy in Spring Festival(Nim博弈)
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1850问题描述Being a Good Boy in Spring FestivalTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s):...原创 2018-10-06 10:57:23 · 149 阅读 · 0 评论 -
LeetCode 105. Construct Binary Tree from Preorder and Inorder Traversal(二叉树)
题目来源:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/问题描述105.Construct Binary Tree from Preorder and Inorder TraversalMedium155841FavoriteShareGiven ...原创 2019-04-05 00:54:15 · 300 阅读 · 0 评论 -
LeetCode 50. Pow(x, n)(分治)
题目来源:https://leetcode.com/problems/powx-n/问题描述50.Pow(x, n)MediumImplementpow(x,n), which calculatesxraised to the powern(xn).Example 1:Input: 2.00000, 10Output: 1024.00000Examp...原创 2019-04-10 14:05:14 · 144 阅读 · 0 评论 -
LeetCode 46. Permutations(dfs)
题目来源:https://leetcode.com/problems/permutations/问题描述46.PermutationsMediumGiven a collection ofdistinctintegers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1...原创 2019-04-08 11:38:09 · 203 阅读 · 0 评论 -
LeetCode 52. N-Queens II(dfs)
题目来源:https://leetcode.com/problems/n-queens-ii/问题描述52.N-Queens IIHardThen-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Gi...原创 2019-04-11 17:09:04 · 134 阅读 · 0 评论 -
LeetCode 206. Reverse Linked List(链表)
题目来源:https://leetcode.com/problems/reverse-linked-list/问题描述206.Reverse Linked ListEasyReverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3...原创 2019-03-29 10:04:07 · 136 阅读 · 0 评论 -
概率算法题两则:蓄水池抽样与概率生成器组合(百度)
概率算法题两则:蓄水池抽样与概率生成器组合蓄水池抽样蓄水池抽样问题的定义:有一个很长的序列,其长度不可知,要提出一种算法,从其中等概率地抽取n个元素直接解决这个问题比较困难,因此提出一个简单一些的问题:如何在长度为m的序列中等概率地抽取n个元素用一个随机数生成器rand生成n个随机概率然后根据这n个概率去序列中取对应索引的元素显然是不可行的,因为可能会有重复的元素为了解决这个问题,需要把...原创 2019-09-04 22:02:29 · 307 阅读 · 0 评论 -
POJ 2823 Sliding Window(线段树)
题目来源:http://poj.org/problem?id=2823问题描述Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 70616 Accepted: 20045 Cas...原创 2018-08-10 20:50:37 · 240 阅读 · 1 评论