【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

注意那个星号的数量。。。
然后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(int x,int y,int p){
for (int i = 1;i <= p;i++)
if (a[x][y][0]){
y++;
if (y>n) break;
}else return 0; for (int i = 1;i <= p;i++)
if (a[x][y][1]){
x++;
if (x>n) break;
}else return 0; for (int i = 1;i <= p;i++)
if (y-1>=1 && a[x][y-1][0]){
y--;
if (y<1) break;
}else return 0; for (int i = 1;i <= p;i++)
if (x-1>=1 && a[x-1][y][1]){
x--;
if (x<1) break;
}else return 0;
return 1;
} int main(){
//freopen("/home/ccy/rush.txt","r",stdin);
//freopen("/home/ccy/rush_out.txt","w",stdout);
ios::sync_with_stdio(0),cin.tie(0);
int kase = 0;
while (cin >> n){
if (kase>0){
cout<<endl;
cout<<"**********************************"<<endl;
cout<<endl;
}
cout<<"Problem #"<<++kase<<endl<<endl;
memset(a,0,sizeof a);
memset(cnt,0,sizeof cnt);
cin >> m;
for (int i = 1;i <= m;i++){
char s[5];int x,y;
cin >> s >> x >> y; if (s[0]=='H')
a[x][y][0] = 1;
else{
swap(x,y);
a[x][y][1] = 1;
}
}
for (int p = 1;p <= n;p++)
for (int i = 1;i <= n;i++)
for (int j = 1;j <= n;j++)
if (check(i,j,p))
cnt[p]++;
bool none = 1;
for (int i = 1;i <= n;i++){
if (cnt[i]>0) {
none = 0;
cout<<cnt[i]<<" square (s) of size "<<i<<endl;
} }
if (none) cout<<"No completed squares can be found."<<endl;
}
return 0;
}

【习题 4-2 Uva201】Squares的更多相关文章

  1. uva201 Squares

     Squares  A children's board game consists of a square array of dots that contains lines connecting ...

  2. [刷题]算法竞赛入门经典(第2版) 4-2/UVa201 - Squares

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,20 ms) #include<iostream> #include<cs ...

  3. 算法习题---4-2正方形(UVa201)

    一:题目 判断一个点阵中含有几个正方形(数正方形) 如图例中:有2个边长为1的正方形,1个边长为2的正方形 (一)题目详解 (二)样例输入 4 表示每行每列各有4个顶点 16 表示整个点阵中共有16条 ...

  4. 【习题 7-6 UVA - 12113】Overlapping Squares

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 先预处理出来一个正方形. 然后每次枚举新加的正方形左上角的坐标就可以. 注意覆盖的规则,控制一下就可以. 然后暴力判断是否相同. 暴 ...

  5. [LeetCode] Word Squares 单词平方

    Given a set of words (without duplicates), find all word squares you can build from them. A sequence ...

  6. Sharepoint学习笔记—习题系列--70-576习题解析 --索引目录

        Sharepoint学习笔记—习题系列--70-576习题解析  为便于查阅,这里整理并列出了70-576习题解析系列的所有问题,有些内容可能会在以后更新. 需要事先申明的是:     1. ...

  7. 卡通图像变形算法(Moving Least Squares)附源码

    本文介绍一种利用移动最小二乘法来实现图像变形的方法,该方法由用户指定图像中的控制点,并通过拖拽控制点来驱动图像变形.假设p为原图像中控制点的位置,q为拖拽后控制点的位置,我们利用移动最小二乘法来为原图 ...

  8. 《python核心编》程课后习题——第三章

    核心编程课后习题——第三章 3-1 由于Python是动态的,解释性的语言,对象的类型和内存都是运行时确定的,所以无需再使用之前对变量名和变量类型进行申明 3-2原因同上,Python的类型检查是在运 ...

  9. Leetcode: Word Squares && Summary: Another Important Implementation of Trie(Retrieve all the words with a given Prefix)

    Given a set of words (without duplicates), find all word squares you can build from them. A sequence ...

随机推荐

  1. Java 二进制和十进制互转,二进制和BitSet互转

    /** * 二进制转十进制 * * @param binaryNumber * @return */ public static int binaryToDecimal(int binaryNumbe ...

  2. acdream 1414 Geometry Problem

    Geometry Problem Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)    ...

  3. java 语法 —— final

    final 成员变量的初始化问题: 1. 实现特别的约束和限制 指向一个 static 型私有成员(仅调用一次), public class Coffee { private static long ...

  4. 【POJ 2442】 Sequence

    [题目链接] http://poj.org/problem?id=2442 [算法] 堆 [代码] #include <algorithm> #include <bitset> ...

  5. PCB MS SQL 排序应用---相邻数据且相同合并处理

    这是一个很有趣SQL数据处理应用,具体需求如下 ERP需要工程将物料编码相邻的编码合并求和BOM用量,巧妙的用到了已有排序号与分组排序号之间的差值求解 示例: 原数据: 要求转换: 实际转换后数据: ...

  6. E20170906-mk

    portrait   n. 肖像,肖像画; 模型,标本; 半身雕塑像; 人物描写; orientation  n. 方向,定位,取向,排列方向; 任职培训; (外交等的) 方针[态度]的确定; 环境判 ...

  7. Java.HttpClient绕过Https证书解决方案一

    方案1 import javax.net.ssl.*; import java.io.*; import java.net.URL; import java.security.KeyManagemen ...

  8. Laravel5.1学习笔记6 响应

    基本响应 附加头信息到响应 附加Cookie到响应 其他响应 View视图响应 JSON响应 File下载 重定向 重定向到命名路由 重定向到控制器Action 附带闪回Session数据重定向 响应 ...

  9. 【转】js中几种实用的跨域方法原理详解

    这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同域的框架中(iframe)的数据.只要协议.域名.端口有任何一个不同,都被 ...

  10. 非内置浏览器WebView 调起H5支付,提示商家参数格式有误

    微信H5 支付开发官方文档参考资料: https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_4 0. 场景描述:在APP 中使用webVie ...