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 ...
随机推荐
- javascript语法详解
javascript语法:运算符 条件语句if...else... 条件语句switch 循环语句for 循环语句while 跳转语句 js运算符 1.算数运算符:+ - * % / ++ ...
- windows下 mysql忘记密码怎么办
第一种: 1. 关闭正在运行的MySQL服务. (先查看mysql是否重命名,net start)2. 打开DOS窗口,转到mysql\bin目录. 3. 输入mysqld --skip-grant- ...
- PAT乙级 1030. 完美数列(25)
1030. 完美数列(25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CAO, Peng 给定一个正整数数列,和正整数p,设这 ...
- [Ubuntu] Ubuntu搭建VPN服务器pptpd
在 Ubuntu 上搭建 VPN 服务器的方法非常多,比较著名的有 PPTP, L2TP/IPSec 和 OpenVPN. 这三种方式中后两者的安全性比较好,但配置较麻烦.其中 OpenVPN 在 W ...
- 【ruby】安装Ruby
系统需求 首先确定操作系统环境,不建议在 Windows 上面搞,所以你需要用: Mac OS X 任意 Linux 发行版本 配置系统包 $ sudo apt-get install -y buil ...
- 【转】The Attached Behavior Pattern
原文:http://www.bjoernrochel.de/2009/08/19/the-attached-behavior-pattern/ The Attached Behavior Patter ...
- 鸟哥的linux私房菜学习记录之档案权限与目录配置
在linux中可以通过ls来查看文件 如ls -al,可以看到类似以下的内容 给个例子来理解下 在目录中如果只有r权限没有x权限无法进入该目录
- Servlet概念框架
以 Servlet 3.0 源代码为基础.Servlet 是 Javaweb 应用的基础框架,犹如孙子兵法之于作战指挥官,不可不知. 概念框架 机制: 事件 Event, 监听器 Listener 数 ...
- java总结第二次(剩余内容)//类和对象1
7.成员变量和局部变量 成员变量:在类中定义,用来描述对象将要有什么 局部变量:在类的方法中定义,在方法中保存临时数据 区别:作用域不同 局部变量的作用域仅限于定义它的方法 成员变量的作用域在整个类内 ...
- 【python cookbook】【数据结构与算法】12.找出序列中出现次数最多的元素
问题:找出一个元素序列中出现次数最多的元素是什么 解决方案:collections模块中的Counter类正是为此类问题所设计的.它的一个非常方便的most_common()方法直接告诉你答案. # ...