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个元 ...
随机推荐
- 《高级Web应用程序设计》课件(20170911)
第一阶段:千里之行,始于足下 第1章 ASP.NET MVC概述 第2章 音乐商店制作 第二阶段:欲穷千里目,更上一层楼 第3章 设计模型 3.1 数据模型概述 3.2 使用EF Code First ...
- ubuntu 安装包过程中遇到的一个错误解决办法
错误提示如下: 将会安装下列额外的软件包: libdigest-hmac-perl libqt5test5下列[新]软件包将被安装: libdigest-hmac-perl下列软件包将被升级: lib ...
- Android我的便签-----SQLite的使用方法
在Android开发中也有数据库的存在,最近有空,把以前写的一个便签来讲述一下Android中的数据库,跟大家分享分享的,希望对大家有所帮助. SQLite简介 SQLite,是一款轻量级的关系型数据 ...
- ffmpeg播放RTSP的一点优化
简单记录一下最近使用ffmpeg播放RTSP做的一点参数优化. 先做如下定义: AVDictionary* options = NULL; 1.画质优化 原生的ffmpeg参数在对1920x1080的 ...
- 使用Easy4net编写代码生成器
在项目中经常要手动创建和数据库对应的实体类,如果数据库表比较多或者表字段比较多,那会是一个工作量非常大的事情,所以我根据自己的需求写了一个简单的代码生成工具,工具使用Easy4net框架开发. 下面是 ...
- C# 实现QQ式截图功能
这个功能一共有两部分组成,第一部分是窗体代码,另外的一部分是一个辅助方法.直接贴出代码,以供大家参考: using System; using System.Collections.Generic; ...
- tsl/ssl 证书制作记录
生成自签名证书 生成服务端秘钥 $ openssl genrsa -out server.key 1024 生成证书请求文件 编写配置文件openssl.cnf $ vi openssl.cnf [r ...
- vector概念
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- asp.net string有多行文字
用如下格式设置
- java入门学习(5)—面向对象注意点总结
1.一个类里面最多有5种成份(属性,方法,构造器,还有两种还没有涉及). 2.定义方法时又返回值的保证最起码有一个有效的return语句,最起码让其在编译的时候就识别到,而不是经过判断识别,如通过if ...