zoukankan      html  css  js  c++  java
  • uva 201 Squares 暴力

    暴力

    把边的信息装到一个field数组里面

    第一维存水平线 第二维存竖直线

    多重循环

    先从边长为1正方形开始检查

    每次检查都重新扫一下它的外圈

    注意竖直线的地方它先给列坐标再给行坐标

    输出有些繁琐

    注意输出空行还有星星

    弱校连萌题目链接:http://acm.bnu.edu.cn/v3/contest_show.php?cid=5772#problem/B

    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <iostream>
    #include <algorithm>
    #include <cmath>
    #include <set>
    #include <queue>
    #include <stack>
    #include <map>
    #include <vector>
    
    using namespace std;
    
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int, int> P;
    
    const int maxn = 1100;
    int field[2][10][10];
    int cnt[10];
    
    int main()
    {
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    
        int n, m;
        int kase = 0;
        while(scanf("%d%d", &n, &m) == 2)
        {
            memset(field, 0, sizeof(field));
            memset(cnt, 0, sizeof(cnt));
            ++kase;
    
            if(kase > 1)
                printf("
    **********************************
    
    ");
    
            char buf[10];
            int x, y;
    
            for(int i = 0; i < m; i++)
            {
                scanf("%s%d%d", buf, &x, &y);
                if(buf[0] == 'H')
                    field[0][x][y] = 1;
                else if(buf[0] == 'V')
                    field[1][y][x] = 1;
            }
    
    
            for(int s = 1; s < n; s++)
            {
                for(int i = 1; i <= n - s; i++)
                {
                    for(int j = 1; j <= n - s; j++)
                    {
                        bool judge = true;
                        for(int t = 0; t < s && judge; t++)
                            if(field[0][i][j+t] != 1)
                                judge = false;
                        for(int t = 0; t < s && judge; t++)
                            if(field[0][i+s][j+t] != 1)
                                judge = false;
                        for(int t = 0; t < s && judge; t++)
                            if(field[1][i+t][j] != 1)
                                judge = false;
                        for(int t = 0; t < s && judge; t++)
                            if(field[1][i+t][j+s] != 1)
                                judge = false;
                        if(judge)
                            cnt[s]++;
                    }
                }
            }
    
            int flag = false;
            printf("Problem #%d
    
    ", kase);
            for(int i = 1; i <= 9; i++)
            {
                if(cnt[i] > 0)
                {
                    flag = true;
                    printf("%d square (s) of size %d
    ", cnt[i], i);
                }
            }
            if(!flag)
                printf("No completed squares can be found.
    ");
    
    
        }
    
        return 0;
    }
  • 相关阅读:
    MS SQL数据库在FAT32格式下数据大小不能超过4G
    屏蔽五项功能 让Windows XP极速狂飙
    FastReport安装
    电脑总是死机
    Win XP控制台命令详解
    一个人独自去看海
    my best love lover
    我的第一个blog
    我的学习生涯
    Codeforces Round #323 (Div. 2) C. GCD Table
  • 原文地址:https://www.cnblogs.com/dishu/p/4265249.html
Copyright © 2011-2022 走看看