Codeforces Round #249 (Div. 2)-D
这场的c实在不想做,sad。
D:
标记一下每个点8个方向不经过黑点最多能到达多少个黑点。
由题意可知。三角形都是等腰三角形,那么我们就枚举三角形的顶点。
对于每个定点。有8个方向能够放三角形。
然后枚举8个方向。然后枚举腰的长度。然后推断是否可行。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
int maps[501][501];
char str[501];
int dx[11]= {-1, 0, 1, 0,-1, -1, 1, 1,-1,-1};
int dy[11]= { 0, 1, 0,-1, 0, 1, 1,-1,-1, 1};
int dp[550][550][10];
int n,m;
int pan(int x,int y)
{
if(x<1||x>n||y<1||y>m)return 1;
if(maps[x][y])return 1;
return 0;
}
int main()
{
while(~scanf("%d%d",&n,&m))
{
for(int i=1; i<=n; i++)
{
scanf("%s",str);
for(int j=1; j<=m; j++)
{
if(str[j-1]=='0')maps[i][j]=0;
else maps[i][j]=1;
}
}
int ans=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
if(maps[i][j])continue;
for(int q=0;q<9;q++)
{
dp[i][j][q]=1;
if(q==4)continue;
for(int k=1;;k++)
{
int xx=i+dx[q]*k;
int yy=j+dy[q]*k;
if(pan(xx,yy))break;
dp[i][j][q]++;
}
}
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
if(maps[i][j])continue;
for(int q=0; q<9; q++)
{
if(q==4)continue;
for(int k=1; ; k++)
{
int xx=i+dx[q]*k;
int yy=j+dy[q]*k;
if(pan(xx,yy)||pan(i+dx[q+1]*k,j+dy[q+1]*k))
{
break;
}
if(q==0&&dp[xx][yy][6]>=k+1)ans++;
if(q==1&&dp[xx][yy][7]>=k+1)ans++;
if(q==2&&dp[xx][yy][8]>=k+1)ans++;
if(q==3&&dp[xx][yy][5]>=k+1)ans++;
if(q==5&&dp[xx][yy][2]>=k*2)ans++;
if(q==6&&dp[xx][yy][3]>=k*2)ans++;
if(q==7&&dp[xx][yy][0]>=k*2)ans++;
if(q==8&&dp[xx][yy][1]>=k*2)ans++;
//cout<<i<<" "<<j<<" "<<q<<" "<<k<<endl;
}
}
}
}
cout<<ans<<endl;
}
return 0;
}
Codeforces Round #249 (Div. 2)-D的更多相关文章
- 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
- Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!
http://codeforces.com/contest/435/problem/C
- Codeforces Round #249 (Div. 2)B(贪心法)
B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #249 (Div. 2) A题
链接:http://codeforces.com/contest/435/problem/A A. Queue on Bus Stop time limit per test 1 second m ...
- Codeforces Round #249 (Div. 2) D. Special Grid 枚举
题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...
- Codeforces Round #249 (Div. 2) 总结
D.E还是很难的.....C不想多说什么... A:提意:给出每一组人的个数,以及一次车载容量,求出最少需要多少次才能载走所有的人. water: http://codeforces.com/cont ...
- Codeforces Round #249 (Div. 2) (模拟)
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #249 (Div. 2) C. Cardiogram
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #249 (Div. 2) A. Black Square
水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...
- Codeforces Round #249 (Div. 2) B. Pasha Maximizes
看到题目的时候,以为类似插入排序,比较第i个元素和第i-1个元素, 如果第i个元素比第i-1个元素小,则不交换 如果第i个元素比第i-1个元素大,则交换第i个元素和第i-1个元素 继续比较第i-1个元 ...
随机推荐
- C++(三十一) — 静态成员变量、静态成员函数
1.静态成员变量 类的静态成员变量是,由该类的所以对象共同维护和使用的数据成员,每个类只有一个副本,是类数据成员的一种特例.采用 static 关键字声明. 目的:实现同一类中不同对象之间的数据共享. ...
- Gruntjs提高生产力(二)
摆脱混乱的html文件中开发,拥有development与product模式是我们梦寐以求的. 我买的需求是: 1.产出一定格式的目录结构,以供日常开发使用,脚手架功能. 2.在开发模式环境中我们按照 ...
- jmap和jstack使用
http://blog.csdn.net/sinat_29581293/article/details/70214436
- Python3 数字Number(六)
Python 数字数据类型用于存储数值. 数据类型是不允许改变的,这就意味着如果改变数字数据类型得值,将重新分配内存空间. 以下实例在变量赋值时 Number 对象将被创建: var1 = 1 var ...
- Flask-WTF表单
Web表单 Web 表单是 Web 应用程序的基本功能. 它是HTML页面中负责数据采集的部件.表单有三个部分组成:表单标签.表单域.表单按钮.表单允许用户输入数据,负责HTML页面数据采集,通过表单 ...
- 剑指offer--51.表示数值的字符串
正则好舒服, ------------------------------------------------------------------------------------------ 时间 ...
- 解决SQL SERVER数据库备份时出现“操作系统错误5(拒绝访问)。BACKUP DATABASE 正在异常终止。”错误的解决办法
SQL SERVER数据库进行备份时出现“操作系统错误5(拒绝访问).BACKUP DATABASE 正在异常终止.”错误.我们应该如何解决这个问题?小编今天为大家推荐一个解决办法. 一般备份文件选择 ...
- 微信测试帐号如何设置URL和Token,以及相关验证的原理
首先说明,本帮助文档是利用javaweb的Servlet来进行“接口配置信息配置信息”认证的. 在学习微信公众号开发的时候,读到填写服务器配置的帮助部分,总是不能理解为啥按照他的步骤做总是设置失败(吐 ...
- .net MVC3 架构搭建描述
用visual studio创建.net MVC3 web项目时,默认情况下是将Views,Controllers,Models创建在一个项目中. 需要把Controllers和Models做为两个独 ...
- iOS的坑:ERRORITMS-90096: "Your binary is not optimized for iPhone 5 - New iPhone appsand app updatesXcode7提交到App Store二进制文件时报错错误:“你itms-90096二进制不是iPhone 5的新iPhone应用程序和应用程序的更新必须提交支持iPhone 5英寸的显示器........
在工程里的Images.xcassets添加并设置LaunchImage对解决ERROR ITMS-90096根本不会起到任何作用,需要单独添加针对iPhone 5的载入图片.关键点有三项: 1.图片 ...