• Cutie Pie


    <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!
    ");
    		else
    			printf("Sorry Man
    ");
        }
        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!
    ");
    		else
    			printf("Sorry Man
    ");
        }
        return 0;
    }
  • 相关阅读:
    海康威视DS-A80648S管理系统配置
    海康威视iVMS-8700平台录像计划——配置CVR存储
    架构师成长之路5.7-Saltstack数据系统
    架构师成长之路5.6-Saltstack配置管理(jinja模板)
    架构师成长之路5.5-Saltstack配置管理(状态间关系)
    架构师成长之路5.4-Saltstack配置管理(LAMP架构案例)
    架构师成长之路5.3-Saltstack配置管理(State状态模块)
    架构师成长之路5.2-Saltstack远程执行
    架构师成长之路5.1-Saltstack安装及入门
    16 Zabbix4.4.1系统告警“Zabbix agent is not available (for 3m)“
  • 原文地址:https://www.cnblogs.com/zcy19990813/p/9702819.html
Copyright © 2020-2023  润新知