hdu1251统计难题
来源:互联网 发布:javascript动态效果图 编辑:程序博客网 时间:2024/06/05 11:24
只想说句空间被狗日了。。。。。
/*****************************************Author :Crazy_AC(JamesQi)Time :2016File Name :*****************************************/// #pragma comment(linker, "/STACK:1024000000,1024000000")#include <iostream>#include <algorithm>#include <iomanip>#include <sstream>#include <string>#include <stack>#include <queue>#include <deque>#include <vector>#include <map>#include <set>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <climits>using namespace std;#define MEM(x,y) memset(x, y,sizeof x)#define pk push_backtypedef long long LL;typedef unsigned long long ULL;typedef pair<int,int> ii;typedef pair<ii,int> iii;const double eps = 1e-10;const int inf = 1 << 30;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;const int maxn = 1000005;const int maxm = 26;struct Tire {int num;int g[maxn][maxm];int val[maxn];void init();int getid(char c);void insert(char *s);int find(char *s);}solve;void Tire::init() {num = 1;val[0] = 0;memset(g[0], 0,sizeof g[0]);}int Tire::getid(char c) {return c - 'a';}int Tire::find(char *s) {int u = 0;int len = strlen(s);for (int i = 0;i < len;++i) {int id = getid(s[i]);if (g[u][id] == 0) return 0;u = g[u][id];}return val[u];}void Tire::insert(char *s) {int u = 0;int len =strlen(s);for (int i = 0;i < len;++i) {int id = getid(s[i]);if (g[u][id] == 0) {val[num] = 0;memset(g[num],0,sizeof g[num]);g[u][id] = num++;}u = g[u][id];val[u]++;}}int main(){// freopen("in.txt","r",stdin);// freopen("out.txt","w",stdout);char s[11];solve.init();while(gets(s) && strcmp(s, ""))solve.insert(s);while(gets(s))printf("%d\n", solve.find(s));return 0;}
0 0
- 统计难题 hdu1251
- HDU1251统计难题
- 统计难题 hdu1251
- HDU1251-统计难题
- 【统计难题】 hdu1251
- hdu1251统计难题
- hdu1251(统计难题)
- HDU1251:统计难题
- hdu1251统计难题
- HDU1251 统计难题
- hdu1251 统计难题 (Trie)
- hdu1251 统计难题 trie
- HDU1251-统计难题
- hdu1251 统计难题
- hdu1251-统计难题
- Hdu1251 统计难题
- hdu1251统计难题
- C++统计难题hdu1251
- 时间戳和日期相互转换
- 机器学习中常用的矩阵求导公式
- Windows7和linux双系统安全删除linux
- java提高篇-----详解java的四舍五入与保留位
- linux c++ 服务器端开发面试必看书籍
- hdu1251统计难题
- 数据挖掘与技术:通过规范化变换数据
- JavaFx Notes
- V4L2应用程序框架
- 详解css3中webkit-animation
- 各种简单的困难的模板,持续更新
- Android学习心得第三课
- 矩阵的转置 C语言
- python装饰器的学习笔记三