03 2018 档案

摘要:网易实习生 题解:超大容量背包问题。因为背包容量过大,不能用背包解法。而物品个数最多只有三十个,但是所有状态也高达2^30,所以将所有物品折半dfs 代码: #include<iostream> #include<vector> #include<cstdio> #include<cstring> 阅读全文
posted @ 2018-03-29 11:53 Silence、 阅读(161) 评论(0) 推荐(0)
摘要:5. Longest Palindromic Substring 最长回文子串 题意:找到字符串的最长回文子串(子串是连续的,子序列是可以间断的) 我的解法:将每两个字符中间插入一个‘#’,这个就可以一起判断奇数回文串和偶数回文串,分别将每个字符作为中心往两侧最长回文,更新结果。时间复杂度O(n^2 阅读全文
posted @ 2018-03-23 14:45 Silence、 阅读(128) 评论(0) 推荐(0)
摘要:1、priority_queue自定义比较结构 class Solution { public: struct cmp { bool operator()(int &a, int &b) const { //因为优先出列判定为!cmp,所以反向定义实现最小值优先 return a>b; } }; v 阅读全文
posted @ 2018-03-15 10:03 Silence、 阅读(155) 评论(0) 推荐(0)