这场的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. iPhone 和Android应用,特殊的链接:打电话,短信,email

    下面的这篇文章主要是说,网页中的链接如何写,可以激活电话的功能. 例如,页面中展示的是一个电话号码,当用户在手机浏览器里面点击这个电话号码的时候,手机会弹出拨号的面板,或者是短信程序会启动等. 1. ...

  2. psd-面试-dp/LCS

    链接:https://www.nowcoder.com/acm/contest/90/D来源:牛客网 掌握未来命运的女神 psd 师兄在拿了朝田诗乃的 buff 后决定去实习. 埃森哲公司注册成立于爱 ...

  3. vue.js 源代码学习笔记 ----- instance init

    /* @flow */ import config from '../config' import { initProxy } from './proxy' import { initState } ...

  4. pcm ulaw alaw转换

    static byte ALawCompressTable[] = { 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5 ...

  5. html与css与JavaScript的关系

    “HTML是网页的结构,CSS是网页的外观,而JavaScript是页面的行为.” 1)HTML—Hypertext Markup Language. 超文本标记语言.用来描述网页的语言. <h ...

  6. 基于Vue的后台选择推荐

    引言: Vue.js目前是业界大名鼎鼎的Web解决方案,具体有点,我这里就不再赘述了,感兴趣的童鞋自行查找阅读,这里罗列一下,这几天自己研究的成果,管理后台. 管理后台 Vue Element Adm ...

  7. [QT]给QApplication安装事件过滤器 app.installEventFilter

    Qt的事件处理有5种级别: 1.      重写控件的事件处理函数:如重写keyPressEvent(),mousePressEvent()和paintEvent(),这是最常用的事件处理方法,我们已 ...

  8. HDU2043 密码

    解题思路:10分钟AC,不解释,so easy! #include<cstdio> #include<cstring> #include<algorithm> us ...

  9. Jmeter-BeanShell Sampler调用java代码

    1.添加BeanShell Sampler 2.编写BeanShell Sampler代码 3.引用参数 ${id}

  10. object references an unsaved transient instance【异常】

    [异常提示] TransientObjectException: object references an unsaved transient instance -save the transient ...