再次回来总结KMP,发现有点力不从心,学久了,越觉得越来越不理解了。估计是写KMP已经不下50遍了吧。每次用都是直接默写。。KMP算法,串模式匹配算法,通过预处理得到next数组,再进行匹配。几个要重点记忆的地方:1. next数组的含义 next[i] = t 表示以i位置结尾的前缀串(相对于原串...
分类:
其他好文 时间:
2014-08-19 00:56:23
阅读次数:
213
#-*-coding:utf-8-*-#python:2.x__author__='Administrator'#迭代器与生成器#---------------------------------------#迭代器基于2个方法"""next:返回容器下一个项目__iter__:返回迭代器本身"""...
分类:
编程语言 时间:
2014-08-19 00:55:53
阅读次数:
253
过程:从右往左,找到第一个A[i] A[i], j > i;交换A[i] 与 A[j];将A[j+1]之后的元素逆序。代码: 1 class Solution { 2 public: 3 void nextPermutation(vector &num) { 4 if(nu...
分类:
其他好文 时间:
2014-08-19 00:48:53
阅读次数:
248
这是一个最短路径的裸题,我们在边结构体中 添加成员路径和花费,然后在松弛操作的时候用这两个来松弛就OK
// AC 840k 109ms
#include
#include
using namespace std;
#define MAX 1001
#define IFN 1<<30-1
struct node
{
int to,len,cost,next;
}edge[MAX*100...
分类:
其他好文 时间:
2014-08-18 20:33:12
阅读次数:
155
/*先吐槽下,刚开始没看懂题,以为只能是一个连通图0T0
题意:给你一个有向图,求G图中从v可达的所有点w,也都可以达到v,这样的v称为sink.求这样的v.
解;求强连通+缩点。求所有出度为0的点即为要求的点。
注意:可能有多个联通分支。
*/
#include
#include
#include
#define N 5100
struct node {
int u,v,w,next;...
分类:
其他好文 时间:
2014-08-18 18:36:42
阅读次数:
225
数组内指针-current()-key()-prev()-next()-reset()-end()预定义数组$_SERVER()$_ENV()$_REQUEST()$_GET()$_POST()$_FILES$_SESSION()$_COOKIE()$GLOBALS()数组的键/值处理相关函数arr...
分类:
Web程序 时间:
2014-08-18 18:10:03
阅读次数:
213
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
* Sort a linked list in O(n log n) time using const...
分类:
其他好文 时间:
2014-08-18 14:31:02
阅读次数:
191
Description
Samball is going to travel in the coming vacation. Now it's time to make a plan. After choosing the destination city, the next step is to determine the travel route. As this poor guy has ...
分类:
其他好文 时间:
2014-08-18 10:50:54
阅读次数:
334
不要把相等运算符(==)与赋值运算符(=)搞混。以&&运算符隔开的两个条件中的前者为错,则不会检测第二个条件的真假。利用这一点,可以提高脚本的速度。使用带switch的多个条件if(button=="next") window.location = "next.html"; else if(b...
分类:
编程语言 时间:
2014-08-17 22:41:13
阅读次数:
180
典型的Joseph问题……由于数据范围小,直接暴力就可以解决了……用到了链表的数据结构……时间:90毫秒。#include "stdio.h"#include "string.h"struct lianbiao{ int prev,next;}p[152];const int INF=2147483...
分类:
其他好文 时间:
2014-08-17 21:15:32
阅读次数:
158