uva201

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n,m,t=0;
    int h[10][10],v[10][10];
    while(~scanf("%d%d",&n,&m))
    {  getchar();
        memset(h,0,sizeof(h));
        memset(v,0,sizeof(v));
        char c;
        int x,y;
        for(int i=0; i<m; i++)
        {
            scanf("%c%d%d",&c,&x,&y);
            getchar();
            if(c==‘H‘)
                h[x][y]=1;
            else
                v[y][x]=1;
        }
        if(t++)
            printf("\n**********************************\n\n");
        printf("Problem #%d\n\n",t);
        int sum=0;
        for(int l=1; l<=n; l++)
        { int con=0;
            for(int i=1; i+l<=n; i++)
                for(int j=1; j+l<=n; j++)
                {
                    int flag=1;
                    for(int k=j; k<j+l; k++)
                        if(!h[i][k]||!h[i+l][k])
                            flag=0;
                    for(int k=i; k<i+l; k++)
                        if(!v[k][j+l]||!v[k][j])
                            flag=0;
                            con+=flag;
                }
                if(con)
                    printf("%d square (s) of size %d\n",con,l);
                sum+=con;
        }
        if(!sum)
            printf("No completed squares can be found.\n");

}
    return 0;
}

时间: 2024-10-05 04:55:33

uva201的相关文章

uva201 Squares

 Squares  A children's board game consists of a square array of dots that contains lines connecting some of the pairs of adjacent dots. One part of the game requires that the players count the number of squares of certain sizes that are formed by the

UVA-201,紫书此处有错

这个题数据小,所以我们暴力可解,思路是这样的:    heng[ i ] [ j ]   一旦是 1 , 就意味着,在( i,j )这个点出发有个 向右的线. zhi[][] 同理,向下的线.然后枚举所有边的情况,一旦judge 函数在某个点,找到了某个 以  len  为边的   完整的方形(len,x,y),就返回1 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int zhi[11][11],heng[11][11]; 5 in

【习题 4-2 Uva201】Squares

[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 注意那个星号的数量... 然后V x y的话,是从(y,x)向(y+1,x)连线. H x y才是从(x,y)向(x,y+1)连线 枚举以(x,y)作为左上角的举行就ok了 [代码] #include <bits/stdc++.h> using namespace std; const int N = 10; int n,m; bool a[N+10][N+10][2]; int cnt[N+5]; bool check(in

2019年7月做题记录

POJ3299 POJ2159 POJ2739 POJ1083 POJ2262 POJ1503 POJ3006 POJ3094 POJ2255 POJ2965 PPOJ1328 POJ2109 POJ2586 UVA227 UVA1368 UVA1589 UVA201 POJ3295 HDU2089 HDU4734 POJ3252 HDU6581 HDU6582 POJ2104 HDU6601 HDU6578 HDU6586 HDU6590 HDU6609 HDU6600 洛谷P1522 洛谷P

算法竞赛入门经典 第四章

[√ ] UVA1339 古老的密码 Ancient Cipher [√ ] UVA489 刽子手的游戏 Hangman Judge [√ ] UVA133 救济金发放 The Dole Queue [√ ] UVA213 信息解码 Message Decoding [√ ] UVA512 追踪电子表格中的单元格 Spreadsheet Tracking [√ ] UVA12412 师兄帮帮忙 A Typical Homework (a.k.a Shi Xiong Bang Bang Mang)