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.

Input

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.

Output

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'.

Example
input
4
smart mark
start tear
abracadabra crab
testyourcode your
output
almost good
almost good
none
good
Note

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的更多相关文章

  1. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  2. 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 ...

  3. 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 ...

  4. 2016 Al-Baath University Training Camp Contest-1 B

    Description A group of junior programmers are attending an advanced programming camp, where they lea ...

  5. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 转:Selenium之CSS Selector定位详解

    CSS selector定位 CSS(Cascading Style Sheets)是一种语言,它被用来描述 HTML 和 XML 文档的样式.  百度输入框: <input name=&quo ...

  2. WinForm利用 WinApi实现 淡入淡出 弹出 效果 仿QQ消息

    消息框: using System.Runtime.InteropServices; namespace Windows_API_实现屏幕右下角_消息框_ { public partial class ...

  3. csuoj 1395: Timebomb

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1395 1395: Timebomb Time Limit: 1 Sec  Memory Limit ...

  4. [转]Chrome 控制台console的用法

    Chrome 控制台console的用法 下面我们来看看console里面具体提供了哪些方法可以供我们平时调试时使用. 目前控制台方法和属性有: ["$$", "$x&q ...

  5. Cocos2d-x游戏开发之计时器

    首先写一个计时器的头文件GameTimer.h: #ifndef _GAME_TIMER_H_ #define _GAME_TIMER_H_ #include "cocos2d.h" ...

  6. Android 播放视频文件

    package com.example.myvideo2; import java.io.File; import android.app.Activity; import android.net.U ...

  7. js 去除空格

    var MAX_PERIOD = $('#MAX_PERIOD').val(); // 借款的最大期限 MAX_PERIOD=Trim(MAX_PERIOD,"g");   //带 ...

  8. session讲解(一)——登录网页练习

    第一:登陆网页的表单页面login.php <body> <h1>登陆</h1> <form action="loginchuli.php" ...

  9. 8007003Windows Update遇到未知错误

    如果在检查更新时收到 Windows Update 错误 80070003,则需要删除 Windows 用于标识计算机更新的临时文件.若要删除临时文件,请停止 Windows Update 服务,删除 ...

  10. Sql Server Analysis Service 处理时找到重复的属性键、找不到属性键错误(转载)

    这是两个非常常见的SSAS处理异常,网上也能找到很多文章讲解决办法,但很少见关于异常原因的分析,先来看看第一个" OLAP 存储引擎中存在错误: 处理时找到重复的属性键",一个维度 ...