这场的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. 转载:Mongodb start

    Mongodb 操作 Start MongoDB The MongoDB instance stores its data files in the /var/lib/mongo and its lo ...

  2. 第三章 如何使用Burp Suite代理

    Burp Proxy 是Burp Suite以用户驱动测试流程功能的核心,通过代理模式,可以让我们拦截.查看.修改所有在客户端和服务端之间传输的数据. 本章主要讲述以下内容: Burp Proxy基本 ...

  3. 搞懂分布式技术12:分布式ID生成方案

    搞懂分布式技术12:分布式ID生成方案 ## 转自: 58沈剑 架构师之路 2017-06-25 一.需求缘起 几乎所有的业务系统,都有生成一个唯一记录标识的需求,例如: 消息标识:message-i ...

  4. 三十 Python分布式爬虫打造搜索引擎Scrapy精讲—将selenium操作谷歌浏览器集成到scrapy中

    1.爬虫文件 dispatcher.connect()信号分发器,第一个参数信号触发函数,第二个参数是触发信号,signals.spider_closed是爬虫结束信号 # -*- coding: u ...

  5. LA-4255 Guess (拓扑排序+构造)

    题目大意:一个未知的整数序列,给出其任意一个区间和的正负,还原这个序列.任意一个满足条件的序列即可. 题目分析:将连续区间和转化为前缀和之差,sumx-1与sumy的大小关系已知,以此建立一条有向边, ...

  6. 002——vue小结

    1.new 一个vue对象的时候你可以设置他的属性,其中最重要的包括三个,分别是:data,methods,watch. 2.其中data代表vue对象的数据,methods代表vue对象的方法,wa ...

  7. Spring入门4.AOP配置深入

    Spring入门4.AOP配置深入 代码下载 链接: http://pan.baidu.com/s/11mYEO 密码: x7wa 前言: 之前学习AOP中的一些概念,包括连接点.切入点(pointc ...

  8. c# 获取随机数字/字符/时间

    using System; using System.Text; namespace HuaTong.General.Utility { /// <summary> /// 随机字符/数字 ...

  9. request参数获取的几种方式

    经常用到Request.QueryString[""]和Request.Form[""]来获取参数值. 今天照常用,ajax方式向后台传参,先用的Request ...

  10. 添加机构organizations模块

    startapp organizations models内容: from django.db import models from datetime import datetime # Create ...