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

【题意】

在这里输入题意

【题解】

注意那个星号的数量。。。
然后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. Ant报错之out of memory

    用Ant打包一个比較大的项目的时候,遇到OutOfMemory的问题,求助于Google和百度,网上的解决方式非常多,可是个人认为不够具体全面.我的问题须要综合两种方法才解决.把方案记下来.以期帮助大 ...

  2. DBCP数据源使用

    DBCP:DataBase Connection Pool 1.须要的jar:commons-dbcp.jar  commons-pool.jar 2.把DBCP的配置文件(dbcpconfig.pr ...

  3. https://www.threatminer.org/domain.php?q=blackschickens.xyz ——域名的信誉查询站点 还可以查IP

    https://www.threatminer.org/domain.php?q=blackschickens.xyz https://www.threatminer.org/host.php?q=6 ...

  4. 91. ExtJS获取父子、兄弟容器元素方法

    转自:https://blog.csdn.net/u014745818/article/details/44957341 1 1.当前对象的父对象(上级对象) this.ownerCt: 2.当前对象 ...

  5. z-index 、层叠上下文、层叠级别、z-index失效

    一.z-index z-index默认处于非激活状态,只有定位元素(即position:relative/absolute/fixed时)才会被激活. z-index与层叠上下文关联. 当z-inde ...

  6. 网络流模板(模板题:POJ1273)

    模板题:POJ1273 EK: #include <queue> #include <cstdio> #include <cstring> #include < ...

  7. (转)用JS实现表格中隔行显示不同颜色

    用JS实现表格中隔行显示不同颜色 第一种: <style> tr{bgColor:expression(     this.bgColor=((this.rowIndex)%2==0 )? ...

  8. informix 通过ADO或ODBC连接提取数据时出现中文乱码的解决方法

    最近在做一个项目,是对INFORMIX数据库的数据进行大数据分析,INFORMIX数据库数据有上亿条,没有linux的Root权限和informix数据的生产权限,只能读取.客户要求结果显示在内网wi ...

  9. 安卓通过UDP协议传输数据,中文乱码的问题

    公司最近需要往智能家居方面发展,需要用到UDP协议传输数据,在网上找到了一些资料,但是发现传输中文的时候有乱码的现象,经过我多番捣鼓,终于解决了这个问题,下面贴上关键代码 客户端: public cl ...

  10. 关于MVC4.0版本以上的RegisterBundles用法

    public class BundleConfig { //新建了一个项目文件,打开App_Start下的BundleConfig看看, public static void RegisterBund ...