摘要:
思路:使用trie树..将电话号码s插入树中,如果发现s的前缀已存在或者是s是前面的号码的前缀,则输出"NO"..全部都成功插入则"YES"这里的trie树要用数组表态实现,动态建树会TLE….数组要开到100000这个数量级…不然会RUNTIME ERRORView Code 1 //Accepted 4484K 172MS C++ 993B 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #define M 10 6 using na 阅读全文
posted @ 2012-08-22 21:35
Wheat″
阅读(154)
评论(0)
推荐(0)
摘要:
最基础的字典树…插入一个串的时候,检查它的前缀是否已存在再检查它是否是前面给出的串的前缀…..View Code 1 //poj 1056 Accepted 176K 0MS C++ 1012B 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #define M 2 6 using namespace std; 7 int ii; 8 bool flag; 9 struct Tree{10 Tree* next[M];11 int val;12 Tree()13... 阅读全文
posted @ 2012-08-22 21:32
Wheat″
阅读(120)
评论(0)
推荐(1)
摘要:
题目大意: 给定一个 N*N 的数组 求以(x1, y1) 为左上角 (x1 + b -1 ,y1 + b -1)为右下角 这个b*b的范围内最大值减最小值看到最大值最小值当然想到RMQ啦View Code //Accepted 27392K 594MS C++ 2416B#include <iostream>#include <stdio.h>#include <cmath>using namespace std;const int maxn = 301;int N;int val[maxn][maxn];int st_min[maxn][maxn][9] 阅读全文
posted @ 2012-08-22 21:28
Wheat″
阅读(134)
评论(0)
推荐(0)
摘要:
题意:给出m个模式和一个文本,求各种模式的出现次数比较裸的AC自动机,成功匹配就计数就是了..View Code 1 //Accepted 3065 281MS 13724K 2340 B C++ 2 3 #include <iostream> 4 #include <cstring> 5 #include <cstdio> 6 #include <cmath> 7 #include <algorithm> 8 using namespace std; 9 const int inf=1<<28; 10 const int 阅读全文
posted @ 2012-08-22 20:34
Wheat″
阅读(143)
评论(0)
推荐(0)
摘要:
题目大意:找出匹配串在父串中出现的次数View Code 1 #include <iostream> 2 #include <string.h> 3 const int MAXN = 1000012; 4 char a[MAXN],b[MAXN];//a主串 b匹配串 5 void get_next(char *pstr,int *next) 6 { 7 int i=0; 8 *next=-1; 9 int j=-1;10 while(*(pstr+i)!='\0')11 {12 if(j==-1||*(pstr+i)==*(pstr+... 阅读全文
posted @ 2012-08-22 20:19
Wheat″
阅读(120)
评论(0)
推荐(0)
摘要:
题意:给出m个模式和一个文本,求各种模式的出现次数比较裸的AC自动机,成功匹配就计数就是了..View Code 1 //Accepted 2896 156MS 23516K 2412 B C++ 2 3 #include <iostream> 4 #include <cstring> 5 #include <cstdio> 6 #include <cmath> 7 #include <algorithm> 8 using namespace std; 9 const int inf=1<<28; 10 const int 阅读全文
posted @ 2012-08-22 20:17
Wheat″
阅读(249)
评论(0)
推荐(0)

浙公网安备 33010602011771号