2016 Al-Baath University Training Camp Contest-1 F
Description
Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a is 'good' if it has a substring which is equal tob. However, a is 'almost good' if by inserting a single letter inside of it, it would become 'good'. For example, if a = 'start' and b = 'tear': bis not found inside of a, so it is not 'good', but if we inserted the letter 'e' inside of a, it will become 'good' ('steart'), so a is 'almost good' in this case. Your task is to determine whether the word a is 'good' or 'almost good' or neither.
The input consists of several test cases. The first line of the input contains a single integer T, the number of the test cases. Each of the following T lines represents a test case and contains two space separated strings a and b, each of them consists of lower case English letters. It is guaranteed that the length of a is between 4 and 1000, and the length of b is exactly 4.
For each test case, you should output one line: if a is 'good' print 'good', if a is 'almost good' print 'almost good', otherwise print 'none'.
4
smart mark
start tear
abracadabra crab
testyourcode your
almost good
almost good
none
good
A substring of string s is another string t that occurs in s. Let's say we have a string s = "abcdefg" Possible valid substrings: "a","b","d","g","cde","abcdefg". Possible invalid substrings: "k","ac","bcef","dh".
题意:两个字符串,如果b的长度为4且为a的子串的话,输出good,如果需a要加一个字符才能符合要求的话,输出almost good,否则输出none
题解:用find就行,b可以分解为三个字符组成的字符串,再判断就行
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s1,s2;
cin>>n;
while(n--)
{
cin>>s1>>s2;
if(s1.find(s2)!=-1)
{
cout<<"good"<<endl;
}
else
{
int flag=0;
for(int i=0; i<s2.length(); i++)
{
string s3="";
for(int j=0; j<s2.length(); j++)
{
if(i!=j)
{
s3+=s2[j];
}
}
if(s1.find(s3)!=-1)
{
flag=1;
}
// cout<<s1.find(s3)<<endl;
}
if(flag)
{
cout<<"almost good"<<endl;
}
else
{
cout<<"none"<<endl;
}
}
}
return 0;
}
2016 Al-Baath University Training Camp Contest-1 F的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)
2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest) Problem A. M ...
- 2016 Al-Baath University Training Camp Contest-1 E
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...
- 2016 Al-Baath University Training Camp Contest-1 B
Description A group of junior programmers are attending an advanced programming camp, where they lea ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 2016 Al-Baath University Training Camp Contest-1 J
Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...
- 2016 Al-Baath University Training Camp Contest-1 I
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...
- 2016 Al-Baath University Training Camp Contest-1 H
Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...
- 2016 Al-Baath University Training Camp Contest-1 G
Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...
随机推荐
- Android深入浅出之Binder机制
一说明 Android系统最常见也是初学者最难搞明白的就是Binder了,很多很多的Service就是通过Binder机制来和客户端通讯交互的.所以搞明白Binder的话,在很大程度上就能理解程序运行 ...
- mysql之触发器before和after的区别
我们先做个测试: 接上篇日志建的商品表g和订单表o和触发器 假设:假设商品表有商品1,数量是10: 我们往订单表插入一条记录: insert into o(gid,much) values(1,20) ...
- php扩展的基本安装
phpize ./config --with-php-config=.. make&make install php.ini
- xla_events
LOOKUP_TYPE LANGUAGE LOOKUP_CODE MEANING DESCRIPTION XLA_EVENT_PROCESS_STATUS US D Draft Draft XLA_E ...
- 典型的检查对float精度理解的代码
-rand()%); vy = ); vz = ); pList_particle[i].m_velocity = Vector3(vx,vy,vz); ... 1,3行代码的vx和vz的值域可以通过 ...
- Spark实战1:shell+独立App使用总结
Spark改进了Hadoop执行非流式算法的需要多次IO的缺陷,Spark的所有操作都是基于RDD弹性分布式数据集这种数据结构的,对RDD的操作主要的操作包括transform和action两种操作. ...
- Calibrating delay loop... 问题以及解决方法(RealARM开发板)
RealARM的210开发板在启动是有时会出现这样的死循环 Calibrating delay loop... ,那么原因是什么呢? 经过查找,发现跟RTC有关,实际上就是晶振和RTC电源的问题.所以 ...
- split function of Perl,Python,Awk
使用中常用到Perl,Python,AWK,R, 虽然Java,C,C++,Vala也学过但是就是不喜欢,你说怎么办. 看来一辈子脚本的命. Perl @rray = split /PATTERN/, ...
- redis监控状态
Redis介绍 Redis是一种高级key-value数据库.它跟memcached类似,不过数据可以持久化,而且支持的数据类型很丰富.有字符串,链表.哈希.集合和有序集合5种.支持在服务器端计算集合 ...
- 为什么anylase和scenaio中的平均响应时间差别会这么大?
场景里的响应时间截图如下所示: 结果里的响应时间截图如下所示: