Cutie Pie

版权声明:转载时 别忘了注明出处 https://blog.csdn.net/ZCY19990813/article/details/79949639
<span style="color:#880000">
</span>

 

Consider a NxM small-letters grid. SVU asked you to check whether this grid is a Cutie Pie or not A grid is a cutie pie if you can find the word "pie" in any direction (vertical, horizontal, and radial). Your program should output "Cutie Pie!" if the grid contains the word "pie" or "Sorry Man" otherwise

Input

The first line contains T 1<=T<=10000 the number of test cases. The followed T lines represent the test cases, each one contains two integers 0 < N,M  ≤  20 then N lines each of them contains M English small-letter separated by space characters. There is a blank line between each two successive test cases.

Output

For each test case output "Cutie Pie!" if the grid in the test case contains the word "pie" or "Sorry Man" otherwise.

Examples

input

Copy

2
3 5
o p r d t
i i i i e
f f s e d

4 3
o p r
o k r
i i u
f f s

output

Copy

Cutie Pie!
Sorry Man

 

<span style="color:#880000">本想用深搜做的,但能力有限,还是直接暴力过吧(虽然不是自己亲自做的^^)</span>
#include <bits/stdc++.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        char s[30][30];
        for(int i=0; i<a; i++)
        {
            for(int j=0; j<b; j++)
            {
                scanf(" %c",&s[i][j]);
            }
        }
        int flag=0;
        for(int i=0; i<a; i++)
        {
            for(int j=0; j<b; j++)
            {
                if(s[i][j]=='p')
		   if((s[i-1][j]=='i'&&s[i-2][j]=='e')||(s[i+1][j]=='i'&&s[i+2][j]=='e')||(s[i][j-1]=='i'&&s[i][j-2]=='e')||(s[i][j+1]=='i'&&s[i][j+2]=='e')||(s[i+1][j+1]=='i'&&s[i+2][j+2]=='e')||(s[i-1][j-1]=='i'&&s[i-2][j-2]=='e')||(s[i+1][j-1]=='i'&&s[i+2][j-2]=='e')||(s[i-1][j+1]=='i'&&s[i-2][j+2]=='e'))
						flag=1;
            }
        }
        if(flag)
			printf("Cutie Pie!\n");
		else
			printf("Sorry Man\n");
    }
    return 0;
} <bits/stdc++.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        char s[30][30];
        for(int i=0; i<a; i++)
        {
            for(int j=0; j<b; j++)
            {
                scanf(" %c",&s[i][j]);
            }
        }
        int flag=0;
        for(int i=0; i<a; i++)
        {
            for(int j=0; j<b; j++)
            {
                if(s[i][j]=='p')
		   if((s[i-1][j]=='i'&&s[i-2][j]=='e')||(s[i+1][j]=='i'&&s[i+2][j]=='e')||(s[i][j-1]=='i'&&s[i][j-2]=='e')||(s[i][j+1]=='i'&&s[i][j+2]=='e')||(s[i+1][j+1]=='i'&&s[i+2][j+2]=='e')||(s[i-1][j-1]=='i'&&s[i-2][j-2]=='e')||(s[i+1][j-1]=='i'&&s[i+2][j-2]=='e')||(s[i-1][j+1]=='i'&&s[i-2][j+2]=='e'))
						flag=1;
            }
        }
        if(flag)
			printf("Cutie Pie!\n");
		else
			printf("Sorry Man\n");
    }
    return 0;
}

Pie

11-12

Problem DescriptionnMy birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several small pieces since that looks messy. This piece can be one whole pie though.nnMy friends are very annoying and if one of them gets a bigger piece than the others, they start complaining. Therefore all of them should get equally sized (but not necessarily equally shaped) pieces, even if this leads to some pie getting spoiled (which is better than spoiling the party). Of course, I want a piece of pie for myself too, and that piece should also be of the same size. nnWhat is the largest possible piece size all of us can get? All the pies are cylindrical in shape and they all have the same height 1, but the radii of the pies can be different.nInputnOne line with a positive integer: the number of test cases. Then for each test case:n---One line with two integers N and F with 1 <= N, F <= 10 000: the number of pies and the number of friends.n---One line with N integers ri with 1 <= ri <= 10 000: the radii of the pies.nOutputnFor each test case, output one line with the largest possible volume V such that me and my friends can all get a pie piece of size V. The answer should be given as a floating point number with an absolute error of at most 10^(-3).nSample Inputn3n3 3n4 3 3n1 24n5n10 5n1 4 2 3 4 5 6 5 4 2nSample Outputn25.1327n3.1416n50.2655

pie

10-20

DescriptionnMy birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several small pieces since that looks messy. This piece can be one whole pie though. nnMy friends are very annoying and if one of them gets a bigger piece than the others, they start complaining. Therefore all of them should get equally sized (but not necessarily equally shaped) pieces, even if this leads to some pie getting spoiled (which is better than spoiling the party). Of course, I want a piece of pie for myself too, and that piece should also be of the same size. nnWhat is the largest possible piece size all of us can get? All the pies are cylindrical in shape and they all have the same height 1, but the radii of the pies can be different. n nInputnOne line with a positive integer: the number of test cases. Then for each test case: n---One line with two integers N and F with 1 <= N, F <= 10 000: the number of pies and the number of friends. n---One line with N integers ri with 1 <= ri <= 10 000: the radii of the pies. n nOutputnFor each test case, output one line with the largest possible volume V such that me and my friends can all get a pie piece of size V. The answer should be given as a floating point number with an absolute error of at most 10^(-3).n nSample Inputn3n3 3n4 3 3n1 24n5n10 5n1 4 2 3 4 5 6 5 4 2n nSample Outputn25.1327n3.1416n50.2655

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭