这场的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的更多相关文章

  1. 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram

    题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...

  2. Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!

    http://codeforces.com/contest/435/problem/C

  3. Codeforces Round #249 (Div. 2)B(贪心法)

    B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. 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 ...

  5. Codeforces Round #249 (Div. 2) D. Special Grid 枚举

    题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...

  6. Codeforces Round #249 (Div. 2) 总结

    D.E还是很难的.....C不想多说什么... A:提意:给出每一组人的个数,以及一次车载容量,求出最少需要多少次才能载走所有的人. water: http://codeforces.com/cont ...

  7. Codeforces Round #249 (Div. 2) (模拟)

    C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  8. Codeforces Round #249 (Div. 2) C. Cardiogram

    C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. Codeforces Round #249 (Div. 2) A. Black Square

    水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...

  10. Codeforces Round #249 (Div. 2) B. Pasha Maximizes

    看到题目的时候,以为类似插入排序,比较第i个元素和第i-1个元素, 如果第i个元素比第i-1个元素小,则不交换 如果第i个元素比第i-1个元素大,则交换第i个元素和第i-1个元素 继续比较第i-1个元 ...

随机推荐

  1. bzoj1001平面图最小割转对偶图最短路

    https://www.lydsy.com/JudgeOnline/problem.php?id=1001 很明显的求对偶图的最短路即可(由于特判写错了一直wa = = ) //#pragma com ...

  2. 二十二 Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy模拟登陆和知乎倒立文字验证码识别

    第一步.首先下载,大神者也的倒立文字验证码识别程序 下载地址:https://github.com/muchrooms/zheye 注意:此程序依赖以下模块包 Keras==2.0.1 Pillow= ...

  3. UVALive-3523 Knights of the Round Table (双连通分量+二分图匹配)

    题目大意:有n个骑士要在圆桌上开会,但是相互憎恶的两个骑士不能相邻,现在已知骑士们之间的憎恶关系,问有几个骑士一定不能参加会议.参会骑士至少有3个且有奇数个. 题目分析:在可以相邻的骑士之间连一条无向 ...

  4. 常用git命令(一)

    git add 命令. 这是个多功能命令:可以用它开始跟踪新文件,或者把已跟踪的文件放到暂存区,还能用于合并时把有冲突的文件标记为已解决状态等. 将这个命令理解为“添加内容到下一次提交中”而不是“将一 ...

  5. 常用的SpringMVC注解

    1.@RequestMapping() 访问链接编写: 例如: (1).请求方法: 访问链接: (2).请求参数和请求头: 访问链接: 2.@PathVariable 例如: 访问链接: 结果显示: ...

  6. Linux:mii-tool命令详解

    mii-tool 用于查看.管理介质的网络接口的状态 语法 mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...] 选项 -V 显示版 ...

  7. 配置mysql 允许远程连接

    今天折腾了好常时间远程连接mysql ,在云服务器里面打开了3306端口,使用了service mysql status查看到mysql进程正常. netstat -anp | grep mysql ...

  8. 【PL/SQL编程】变量和常量

    1. 变量格式 <变量名><数据类型>[(长度):=<初始值>]; v_countryname varchar2(50):='中国'; 2. 常量格式 <常量 ...

  9. word中怎么快速选中光标之前或之后的全部内容?

    在Word中,快速选中=光标之后=的全部内容的快捷键:Ctrl + Shift + End:在Word中,快速选中=光标之前=的全部内容的快捷键:Ctrl + Shift + Home.在Word中, ...

  10. 将window上的项目上传到自己的github

    使用git 1.首先在自己的github上面新建仓库 2.记下远程仓库的地址 3.在要上传的项目的目录下使用git命令进行上传 (1)先git init 初始化本地的仓库 (2)git add -A ...