2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage (Online Mirror, ACM-ICPC Rules, Teams Preferred)
题目链接:http://codeforces.com/problemset/problem/847/I
5 seconds
256 megabytes
standard input
standard output
The Berland's capital has the form of a rectangle with sizes n × m quarters. All quarters are divided into three types:
- regular (labeled with the character '.') — such quarters do not produce the noise but are not obstacles to the propagation of the noise;
- sources of noise (labeled with an uppercase Latin letter from 'A' to 'Z') — such quarters are noise sources and are not obstacles to the propagation of the noise;
- heavily built-up (labeled with the character '*') — such quarters are soundproofed, the noise does not penetrate into them and they themselves are obstacles to the propagation of noise.
A quarter labeled with letter 'A' produces q units of noise. A quarter labeled with letter 'B' produces 2·q units of noise. And so on, up to a quarter labeled with letter 'Z', which produces 26·q units of noise. There can be any number of quarters labeled with each letter in the city.
When propagating from the source of the noise, the noise level is halved when moving from one quarter to a quarter that shares a side with it (when an odd number is to be halved, it's rounded down). The noise spreads along the chain. For example, if some quarter is located at a distance 2 from the noise source, then the value of noise which will reach the quarter is divided by 4. So the noise level that comes from the source to the quarter is determined solely by the length of the shortest path between them. Heavily built-up quarters are obstacles, the noise does not penetrate into them.
The values in the cells of the table on the right show the total noise level in the respective quarters for q = 100, the first term in each sum is the noise from the quarter 'A', the second — the noise from the quarter 'B'.
The noise level in quarter is defined as the sum of the noise from all sources. To assess the quality of life of the population of the capital of Berland, it is required to find the number of quarters whose noise level exceeds the allowed level p.
The first line contains four integers n, m, q and p (1 ≤ n, m ≤ 250, 1 ≤ q, p ≤ 106) — the sizes of Berland's capital, the number of noise units that a quarter 'A' produces, and the allowable noise level.
Each of the following n lines contains m characters — the description of the capital quarters, in the format that was described in the statement above. It is possible that in the Berland's capital there are no quarters of any type.
Print the number of quarters, in which the noise level exceeds the allowed level p.
3 3 100 140
...
A*.
.B.
3
3 3 2 8
B*.
BB*
BBB
4
3 4 5 4
..*B
..**
D...
7
The illustration to the first example is in the main part of the statement.
题解:从每个噪音源点bfs(),然后统计值就可以
#include<bits/stdc++.h>
#define pb push
#define ll long long
#define PI 3.14159265
using namespace std;
const int maxn=;
const int inf=0x3f3f3f3f;
ll n,m,q,p;
bool vis[maxn][maxn];
char mp[maxn][maxn];
int sd[maxn][maxn];
int dx[]={-,,,};
int dy[]={,,-,};
struct node
{
int x,y,z;
};
void bfs(int x,int y)
{
node a,next;
a.x=x;a.y=y;a.z=(mp[x][y]-'A'+)*q;
queue<node>qq;
qq.pb(a);
sd[x][y]+=a.z;
memset(vis,false,sizeof(vis));
vis[x][y]=true;
while(!qq.empty())
{
a=qq.front();
qq.pop();
// if(a.z<=0)continue;
for(int i=;i<;i++)
{
next.x=a.x+dx[i];
next.y=a.y+dy[i];
next.z=a.z/;
if(next.x<||next.x>n||next.y<||next.y>m||mp[next.x][next.y]=='*'||vis[next.x][next.y])continue;
vis[next.x][next.y]=true;
sd[next.x][next.y]+=next.z;
if(next.z>)qq.pb(next);
}
}
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n>>m>>q>>p;
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
cin>>mp[i][j];
}
}
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
if(mp[i][j]>='A'&&mp[i][j]<='Z')
{
bfs(i,j);
}
}
} int ans=;
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
if(sd[i][j]>p)ans++;
}
}
cout<<ans<<endl;
return ;
}
2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage (Online Mirror, ACM-ICPC Rules, Teams Preferred)的更多相关文章
- D. Dog Show 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage (Online Mirror, ACM-ICPC Rules, Teams Preferred)
http://codeforces.com/contest/847/problem/D 巧妙的贪心 仔细琢磨... 像凸包里的处理 #include <cstdio> #include & ...
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage
2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage A. Union of Doubly Link ...
- 2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage(11/12)
2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage A. Coffee Break 排序之后优先队 ...
- 2019.04.18 第六次训练 【2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage】
题目链接: https://codeforces.com/gym/101911 又补了set的一个知识点,erase(it)之后it这个地址就不存在了,再引用的话就会RE A: ✅ B: ✅ C: ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)
i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
随机推荐
- php 学习笔记 一
1.函数不对 case sensitive, 变量 case sensitive 2.全局变量 只能全局用 ,局部变量 只能函数体内用,要在 函数内访问 全局变量 要用 global 关键字申明 ,或 ...
- 分布式memcached-虚拟节点
1.通过memcached服务器下的不同端口来达到模拟多台服务器的效果 2.假设现在有三台memcached服务器,本地分别使用11211,11212,11213三个端口来模拟 ①打开端口 ②连接端口 ...
- TensorFlow构建卷积神经网络/模型保存与加载/正则化
TensorFlow 官方文档:https://www.tensorflow.org/api_guides/python/math_ops # Arithmetic Operators import ...
- 后端路由项目由 gulp 改为 webpack 的踩坑实录
前言 公司有个后端路由的项目是用 gulp 作为前端自动化构建工具,最近学习了一下 webpack,深感其强大,一狠心将其改成了 webpack 构建,以下是踩坑实录. gulp 先来说说原来的架构. ...
- mysql数据类型double和decimal区别详解
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt336 实数是带有小数部分的数字.然而,它们不只是为了存储小数部分,也可以使用 ...
- spring cloud认识
Spring Cloud是一个基于Spring Boot实现的云应用开发工具,它为基于JVM的云应用开发中的配置管理.服务发现.断路器.智能路由.微代理.控制总线.全局锁.决策竞选.分布式会话和集群状 ...
- 通过编译lambda表达式来创建实例(可在反射时候用,效率比反射高一些)
原文地址:https://rogerjohansson.blog/2008/02/28/linq-expressions-creating-objects/ 据说编译lambda创建实例是比反射快.实 ...
- centos 7 && dotnet core 2.0 && nginx && supervisor
前提 系统:centos 7 目录:/home/wwwroot/www.wuball.com dotnet core 2.0 官方指引 sudo rpm --import https://packag ...
- 结对编程1 —— 基于GUI和Swing的四则运算题目生成器
合作伙伴 201421123102 王艳秋 201421123106 陈 雄 代码地址 题目描述 我们在个人作业1中,用各种语言实现了一个命令行的四则运算小程序.进一步,本次要求把这个程序做成GUI( ...
- Java 第五周总结
1. 本周学习总结 2. 书面作业 1.代码阅读:Child压缩包内源代码 1.1 com.parent包中Child.java文件能否编译通过?哪句会出现错误?试改正该错误.并分析输出结果. 不能. ...