zoj 3643 Keep Deleting
来源:互联网 发布:股权投资 知乎 编辑:程序博客网 时间:2024/06/05 05:27
只要看到zoj,就什么题都不会做了。。。
这个题搞了半天KMP,TLE了还是。
比赛结束有人讲了一种方法,用栈去模拟,把b串中的元素一个个入栈,遇到和a相等的就把栈顶出栈。写了几行,过了。
叹水平之差兮……
/* * Author: stormdpzh * Created Time: 2012/8/26 19:32:30 * File Name: k.cpp */#include <iostream>#include <cstdio>#include <sstream>#include <cstring>#include <string>#include <cmath>#include <vector>#include <queue>#include <stack>#include <map>#include <set>#include <list>#include <algorithm>#include <functional>#define sz(v) ((int)(v).size())#define rep(i, n) for(int i = 0; i < n; i++)#define repf(i, a, b) for(int i = a; i <= b; i++)#define repd(i, a, b) for(int i = a; i >= b; i--)#define out(n) printf("%d\n", n)#define mset(a, b) memset(a, b, sizeof(a))#define wh(n) while(1 == scanf("%d", &n))#define whz(n) while(1 == scanf("%d", &n) && n != 0)#define lint long longusing namespace std;const int INF = 1 << 30;const int MaxN = 512005;const int MaxM = 300;char b[ MaxN ];char a[ MaxM ];int len;int len2;char stk[ MaxN ];int gao(){ int top = 0; int i = 0; int cnt = 0; while( i < len ) { stk[ top++ ] = b[ i ]; stk[ top ] = '\0'; if( top >= len2 && strcmp( &stk[ top - len2 ], a ) == 0 ) { cnt++; top = top - len2; } i++; } return cnt;}int main(){ while( 1 == scanf( "%s", a ) ) { scanf( "%s", b ); len = strlen( b ); len2 = strlen( a ); out( gao() ); } return 0;}
- zoj 3643 Keep Deleting
- ZOJ 3643 - Keep Deleting
- ZOJ 3643:Keep Deleting
- zoj 3643 Keep Deleting
- ZOJ-3643-Keep Deleting【字符串】
- ZOJ3643 Keep Deleting
- 字符串处理Keep Deleting
- zoj 2186 Keep on Truckin'
- ZOJ 2186 Keep on Truckin'
- zoj 2186 Keep on Truckin'
- ZOJ 2186 Keep on Truckin'
- ZOJ 2186 Keep on Truckin'
- ZOJ - 2186 Keep on Truckin'
- ZOJ Problem Set - 2186 Keep on Truckin'
- keep
- ZOJ Problem Set - 2186 Keep on Truckin'【模拟】
- Deleting Logs
- Deleting Clients
- poj 1679 prim
- 黑马程序员四、String 类
- [最大流]poj 2112 ptimal Milking#floyd+二分+最大流
- 搜索题目推荐及解题报告
- 分本分类与聚类 笔记
- zoj 3643 Keep Deleting
- localhost与127.0.0.1的区别
- 【PB】如何给datawindow某一列动态设置成dddw或者ddlb,并且赋值?
- 契约(消息契约)
- poj 1365 Prime Land (质因子分解)
- POJ3728-LCA及诸多优化
- 使用Windbg调试内核
- beini奶瓶-无线网络蹭网破解-简明说明
- 数据结构概念