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.

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可以分解为三个字符组成的字符串,再判断就行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#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;
}

  

posted @   樱花落舞  阅读(427)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示