- 博客(13)
- 资源 (1)
- 收藏
- 关注
原创 hdu 4513 吉哥系列故事——完美队形II
hdu 4513 吉哥系列故事——完美队形II 题目给出的整数哦, 不过也完全可以通过manacher算法来实现查找最长的回文哦. 这个道题比平常的回文长度的题目加多一个判断而已啦.#include #include #define MAX 100005#define min(a, b) (a > b ? b : a)int q[MAX], ne
2013-08-31 23:14:34 880
原创 hdu 3294 Girls' research
hdu 3294 Girls' research 找到最长的回文子串并按题目中的字符偏移量输出. 使用manacher算法求解的.#include #define MAX 200005#define min(a, b) (a > b ? b : a)char str[MAX], newStr[MAX*2];char rep[2];int p[MAX*2];in
2013-08-31 23:11:06 548
原创 hdu 3068 最长回文
hdu 3068 最长回文 Manacher算法求最大的回文串长度#include #include int min(int a, int b) { return a > b ? b : a;}char oldStr[110005], newStr[220010];int p[220010];int main() { int max
2013-08-30 23:39:23 538
原创 hdu 4031 Attack
hdu 4031 Attack 童鞋说用树状数组做, 知识点是 区间改,单点查。#include #include #define MAX 20001struct AttackBound { int left, right;};int attackNum[MAX];int lowbit(int x) { return x & (-x);}void
2013-08-29 23:32:49 720
原创 hdu 4027 Can you answer these queries?
hdu 4027 Can you answer these queries? 线段树#include #include #include #define MAX 400000struct node { int left, right; __int64 val; int flag;};node tree[MAX];void buildTree(int
2013-08-29 23:26:46 597
原创 hdu 1754 I Hate it
hdu 1754 I Hate it 线段树#include#include#include#includeusing namespace std;int tree[800005];void build(int left,int right,int root){ if(left==right) { scanf("%d",&tr
2013-08-29 23:24:20 563
原创 hdu 1156 Color the ball
hdu 1156 Color the ball 直接拿数组来做的话会超时...... 那就线段树吧,这道题主要是线段树的更新啦, 只要树上的某个节点的区间符合需要更新的区间,OK,那就只更新该节点就i行了, 而不用一直更新到叶子结点,不然的话效率就降到到O(n^2)了... #include #include #define MAX
2013-08-29 23:20:44 1066
原创 hdu 1075 What Are You Talking Abou
hdu 1075 What Are You Talking About 字典树啦, 指针处理起来要小心一点哦, 而且字典树的代码又有点长, 有模板直接用就很爽啦.#include #include #include #define SIZE 26#define LENGTH 15struct TrieNode { char* en; TrieN
2013-08-27 23:48:10 792
原创 hdu 1372 Knight Moves
hdu 1372 Knight Moves 广搜, 那个Knight是走"日"字的, 就像中古想起里面的马走法一样哦, 那么它在不出范围的情况下就有8个方向哦. #include #include #include using namespace std;struct cell { int x, y; int step;};
2013-08-27 23:40:14 619
原创 hdu 1026 Ignatius and the Princess I
hdu 1026 Ignatius and the Princess I 题目要求的是从(0, 0)到(n-1, m-1)的最小秒数啦, 首先想到的就是广搜啦, 这道题要求输出搜索过的路径哦, 那么就需要一个额外的数组来记录了. 用turn[][]数组来记录每次转过的方向, 一次广搜结束后, 然后再从终点顺着走回来, 就可完成路径的记录啦.#incl
2013-08-27 23:33:05 543
原创 hdu 2616 Kill the monster
hdu 2616 Kill the monster 普通的深搜题目 #include #include #define INF 0xffffffint cSpell[15], dSpell[15];int visited[15];int n, m;int min;void dfs(int hp, int cnt) { int i;
2013-08-27 23:15:19 600
原创 hdu 1166 敌兵布阵
hdu 1166 敌兵布阵 这是一道树状数组的入门题啦. 学习树状数组的时候多拿笔算算就比较好理解为什么算法的查询和修改都是logn的了. c[i] = a[i - 2^k + 1] + a[i - 2^k + 2] + ... + a[i], 其中k为i的二进制表示最后几位零的个数, 如i=8, 那么1000三个0咯, 那么c[8] = a[
2013-08-27 00:14:12 536
原创 hdu 1429 胜利大逃亡(续)
hdu 1429 胜利大逃亡(续) 这是一道广搜题. 刚开始看有点思路, 但是实现起来需要定义一些相关的结构体,比较麻烦.尤其是怎么处理拿到钥匙和开门...... 下面这种方法能为下次做类似的题提供更多的想法. 后来看到了某大神的一种更好的办法来处理钥匙和开门的问题, 那就是位运算来模拟拿钥匙和开门. 看了一篇思路就很清晰了.
2013-08-26 23:33:15 1514
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人