cyk追楠神系列一

Time Limit: 1000MS Memory Limit: 65536KB

Problem Description

众所周知,cyk 是个奇特的人,有一天,他终于又做出了一个惊 (zheng) 人 (chang) 的决定,他决定追楠神了!于是 cyk 就写了一封信向楠神表白。但是楠神作为 acm 的大佬,怎么能轻易答应 cyk,他决定对信做一个考察,为此他特意定义了“爱的证据”,“爱的证据”即如果在信里的一个长度等于 k 的字符子串里包含“love”,那么这就是一个“爱的证据”,比如 k=5 时,字符串“i love you”里“ love”和“love ”就是“爱的证据”。 现在,楠神想知道 cyk 写的信里有多少个“爱的证据”,假如“爱的证据”超过 m,那么他就会答应 cyk,如果小于等于 m,那么他就会丑拒。由于 cyk 的字太丑,所以楠神就把这项任务交给了你。

Input

第一行输入 t (1 <= t <= 100),代表有 t 组输入数据。

每组数据第一行输入 m, k (1 <= m, k <= 10^3)。

第二行输出一个字符串 a,长度不超过 10^3。

Output

每组输出占一行,假如楠神可以答应 cyk,就输出“congratulation”,如果不能就输出“too ugly to accept”。

Example Input

1
1 5
i love you

Example Output

congratulation

Hint

Author

Johsnows 

#include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>

using namespace std;
char b[6]="love";
int main()
{
    int t;
    scanf("%d",&t);

    while(t--)
    {
        int m,k, l,count = 0,o;
        char a[1002];
        scanf("%d%d",&m,&k);getchar();
        gets(a);
        l = strlen(a);
        int i;
        for(i = 0;i<l-k+1;i++)
        {
            int s = 0;
            for(o=i;o<k+i;o++)
            {

               if(b[s]==a[o])
               {
                   s++;
                   if(s==4)
                   {
                       count++;
                       break;
                   }
               }
               else
               {
                   s = 0;
               }
            }
        }
        if(count>m)
        {
            printf("congratulation\n");
        }
        else
            printf("too ugly to accept\n");


    }
    return 0;
}