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 ...
随机推荐
- [转] asp.net <%%>&<%#%>&<%=%>&<%@%>&<%$%>用法区别
转自 参考 1.<% %>用来绑定后台代码 如: < % for(int i=0;i<100;i++) { Reaponse.Write(i.ToString()); } % ...
- 关于C语言链表的学习
今天讲了一种非传统型的链表.听得不是太好. 到数据结构那一部分的时候.一定要好好听听.
- ACdream 1128 Maze(费用流)
题目链接:http://acdream.info/problem?pid=1128 Problem Description wuyiqi陷入了一个迷宫中,这个迷宫是由N*M个格子组成的矩阵.每个格子上 ...
- paper 61:计算机视觉领域的一些牛人博客,超有实力的研究机构等的网站链接
转载出处:blog.csdn.net/carson2005 以下链接是本人整理的关于计算机视觉(ComputerVision, CV)相关领域的网站链接,其中有CV牛人的主页,CV研究小组的主页,CV ...
- MVC4下拉少数名族
List<SelectListItem> nationlist = new List<SelectListItem>() { new SelectListItem(){Valu ...
- IE已经被抛弃,但是不能遗忘
虽然IE的兼容问题,在我写这篇文章的时候基本已经被抛弃了,但是我觉得还是应该了解一下最基本的解决办法. 就像中国的历史已经过去,但是我们不能忘记一样的. 逐个版本解决法 .bb{ background ...
- 使用Application Loader打包上传AppStore流程
配置完你的证书,Bundle Identifier 和描述文件的配置 然后配置工程打开你项目工程 第一步,这里不能选择模拟器,选择iOS Device 如果不支持横屏,把这2个勾去掉 然后查看版本号和 ...
- PHP用substr截取字符串出现中文乱码问题用mb_substr
PHP用substr截取字符串出现中文乱码问题用mb_substr实例:mb_substr('截取中文乱码问题测试',0,5, 'utf-8'); 语法 : string substr (string ...
- Intel+Ardruino 101
为了传说中的那啥, 啊, 嗯.. #include <CurieBLE.h>const int ledPin = 13; // set ledPin to on-board LED LE ...
- Java使用基本字节流OutputStream的四种方式对于数据复制(文本,音视频,图像等数据)
//package 字符缓冲流bufferreaderDemo; import java.io.BufferedOutputStream; import java.io.FileInputStream ...