2018年7月19日
摘要: Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Example 2: Example 3: 阅读全文
posted @ 2018-07-19 20:32 平和之心 阅读(144) 评论(0) 推荐(0) 编辑
2018年7月17日
摘要: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: 阅读全文
posted @ 2018-07-17 21:30 平和之心 阅读(114) 评论(0) 推荐(0) 编辑
2017年5月6日
摘要: 暴力 动态规划: d[i][j]标识s串i到j是回文串。判断d[i][j],只需满足s[i]=s[j],切d[i][j]=true 阅读全文
posted @ 2017-05-06 18:34 平和之心 阅读(113) 评论(0) 推荐(0) 编辑
2017年4月27日
摘要: O(N^2)AC.. 使用hash表优化查询... 阅读全文
posted @ 2017-04-27 23:22 平和之心 阅读(108) 评论(0) 推荐(0) 编辑
2015年5月6日
摘要: 问题:给出一个n结点的图,求最大边与最小边差值最小的生成树 my code: #include #include #include #include #include #include using namespace std; #define N 102 #define INF 0x7fffffff struct Edge { int u, v, w; bool op... 阅读全文
posted @ 2015-05-06 17:31 平和之心 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 问题:输入一个结点的无根树的各条边,并指定一个根结点,要求把该树转化为有根树 测试oj:nyoj http://acm.nyist.net/JudgeOnline/problem.php?pid=20 当结点数很多时若用邻接矩阵存储图将占用很大的空间,此时可使用vector或邻接表存储,由于vector内存的增长方式问题也可能会引起内存过大问题,此时邻接表存储更具优势 代码: 使用vector... 阅读全文
posted @ 2015-05-06 09:27 平和之心 阅读(564) 评论(0) 推荐(0) 编辑
2015年4月13日
摘要: 题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=79题意即求最长单调递减子序列#include#include#includeusing namespace std;#define N 22int h[N];int d[N];int mai... 阅读全文
posted @ 2015-04-13 17:14 平和之心 阅读(174) 评论(0) 推荐(0) 编辑
2015年4月11日
摘要: 题解链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=541 几天前百度题解后用数学知识AC的,后来大牛说这是一道动态规划题。 网上的数学解题链接:http://blog.csdn.net/x314542916/article/details/8 阅读全文
posted @ 2015-04-11 18:33 平和之心 阅读(223) 评论(0) 推荐(0) 编辑
2015年4月9日
摘要: 题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=592 解决以下问题后就方便用广搜解: 1、将数字坐标化,10000坐标为(0,0),这样就可以通过数字获得其坐标 2、通过一个坐标知道在这个位置上的数字是否为素数 #include #include #include #include #include using namespace... 阅读全文
posted @ 2015-04-09 15:43 平和之心 阅读(139) 评论(0) 推荐(0) 编辑
2015年4月8日
摘要: 题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=202 一棵树左旋或者右旋,树的中序遍历保持不变 #include #include #include using namespace std; int ls[25]; int rs[25]; int n; void print(int id) { if(id == -1 ||... 阅读全文
posted @ 2015-04-08 15:48 平和之心 阅读(131) 评论(0) 推荐(0) 编辑