Codeforces Round #342 (Div. 2) B
1 second
256 megabytes
standard input
standard output
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.
This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineapple did their best to postpone the release of Lastus 3000 as long as possible. Finally, they found out, that the name of the new artificial intelligence is similar to the name of the phone, that Pineapple released 200 years ago. As all rights on its name belong to Pineapple, they stand on changing the name of Gogol's artificial intelligence.
Pineapple insists, that the name of their phone occurs in the name of AI as a substring. Because the name of technology was already printed on all devices, the Gogol's director decided to replace some characters in AI name with "#". As this operation is pretty expensive, you should find the minimum number of characters to replace with "#", such that the name of AI doesn't contain the name of the phone as a substring.
Substring is a continuous subsequence of a string.
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
intellect
tell
1
apple
0
sirisiri
sir
2
In the first sample AI's name may be replaced with "int#llect".
In the second sample Gogol can just keep things as they are.
In the third sample one of the new possible names of AI may be "s#ris#ri".
题意: 求母串中有多少子串 (母串中字符只能使用一次)
比赛的时候傻了 本来可以上一波大分 小涨7分 水笔贴水题
贴q神代码 %%%
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
const int MAXM=35;
char s[MAXN],t[MAXM];
int main()
{
scanf("%s%s",s,t);
int n=strlen(s),m=strlen(t);
int res=0;
for(int i=0;i+m<=n;i++)
{
bool flag=1;
for(int j=0;j<m;j++)
if(s[i+j]!=t[j])
flag=0;
if(flag)
{
s[i+m-1]='#';
res++;
}
}
printf("%d\n",res);
return 0;
}
Codeforces Round #342 (Div. 2) B的更多相关文章
- Codeforces Round #342 (Div. 2) D. Finals in arithmetic 贪心
D. Finals in arithmetic 题目连接: http://www.codeforces.com/contest/625/problem/D Description Vitya is s ...
- Codeforces Round #342 (Div. 2) C. K-special Tables 构造
C. K-special Tables 题目连接: http://www.codeforces.com/contest/625/problem/C Description People do many ...
- Codeforces Round #342 (Div. 2) B. War of the Corporations 贪心
B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long ...
- Codeforces Round #342 (Div. 2) A - Guest From the Past 数学
A. Guest From the Past 题目连接: http://www.codeforces.com/contest/625/problem/A Description Kolya Geras ...
- Codeforces Round #342 (Div. 2) E. Frog Fights set 模拟
E. Frog Fights 题目连接: http://www.codeforces.com/contest/625/problem/E Description stap Bender recentl ...
- Codeforces Round #342 (Div. 2) D. Finals in arithmetic(想法题/构造题)
传送门 Description Vitya is studying in the third grade. During the last math lesson all the pupils wro ...
- Codeforces Round #342 (Div. 2) C. K-special Tables(想法题)
传送门 Description People do many crazy things to stand out in a crowd. Some of them dance, some learn ...
- Codeforces Round #342 (Div. 2) B. War of the Corporations(贪心)
传送门 Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Go ...
- Codeforces Round #342 (Div. 2) A. Guest From the Past(贪心)
传送门 Description Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the detai ...
- Codeforces Round #342 (Div. 2)-B. War of the Corporations
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- 一句话描述 Java 设计模式
Java 设计模式 设计模式是对应于不同的应用目的的. 适配:将特定功能接口适配需求方 桥接:面向两个接口,无关接口的实现: 抽象化与实现化解耦,使得二者可以独立变化:例:笔与图形,笔可以画图 ...
- git push origin master 错误解决办法
一.错误代码如下: error: failed to push some refs to 'https://github.com/wbingithub/drag.git' 二.在网上搜了一下,如下写就 ...
- Nodejs Express笔记
Express做服务器,主要考虑到可能存在的高并发,js写起来也并不麻烦,环境搭建也异常简单.开车~ 由于主要目的就是用于生产环境,所以肯定不能用高版本的Nodejs,选LTS,没错的. 一.安装 这 ...
- kubernetes相关
1.获取client , api-server 加token 或in-cluster方式 2.所有对象均有list update get 等方法 3.对象属性源码追踪,yaml与源码一一对应 4.一些 ...
- AttributeError: 'TimeLimit' object has no attribute 'monitor'
原报错代码部分: env.monitor.start(monitor_path, resume=True, video_callable=lambda count: count % record_vi ...
- [LeetCode] 53. Maximum Subarray 解题思路
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- js经典试题之ES6
js经典试题之ES6 1:在ECMAScript6 中,Promise的状态 答案:pending resolved(fulfilled) rejected 解析: Promise对象只有三种状态: ...
- asp.net中Repeater结合js实现checkbox的全选/全不选
前台界面代码: <input name="CheckAll" type="checkbox" id="CheckAll" value= ...
- 解决编写 xml 没有代码提示
有时候在编写 struts.xml 会没有代码提示,一般是因为没有联网导致的,或者之前配置过 dtd 文件 url,但是文件路径之后被修改了. 解决方案有: 让电脑联网 修改 dtd 的本地路径以及 ...
- Error:Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Request"
(1) 网上下载了一个android应用:死活用不了,查了以下,原来是android studio版本不对,于是把android studio的版本从2.2 升级到3.0,后来发现没法升级,只能下载, ...