当前位置:网站首页>P1789 [MC survival] torch [introduction]
P1789 [MC survival] torch [introduction]
2022-07-18 18:27:00 【Programmed Luna】
【Mc Existence 】 Insert a torch
Title Description
Say one day linyorson stay “ My world ” Opened one n × n n \times n n×n Matrix of , Now he has m m m A torch and k k k A fluorite , We separate ( x 1 , y 1 ) ∼ ( x m , y m ) (x_1, y_1) \sim (x_m, y_m) (x1,y1)∼(xm,ym) and ( o 1 , p 1 ) ∼ ( o k , p k ) (o_1, p_1) \sim (o_k, p_k) (o1,p1)∼(ok,pk) The location of , There are monsters where there is no light or nothing . How many points in this square array will generate monsters ?
P.S. The scope of the torch is :
| dark | dark | light | dark | dark |
| dark | light | light | light | dark |
| light | light | Torch | light | light |
| dark | light | light | light | dark |
| dark | dark | light | dark | dark |
Fluorite :
| light | light | light | light | light |
| light | light | light | light | light |
| light | light | Fluorite | light | light |
| light | light | light | light | light |
| light | light | light | light | light |
Input format
Input common m + k + 1 m + k + 1 m+k+1 That's ok .
First act n , m , k n, m, k n,m,k.
The first 2 2 2 To the first m + 1 m + 1 m+1 OK, the positions of the torches x i , y i x_i, y_i xi,yi.
The first m + 2 m + 2 m+2 To the first m + k + 1 m + k + 1 m+k+1 The lines are the positions of fluorite o i , p i o_i, p_i oi,pi.
notes : Maybe no fluorite , But there must be a torch .
Output format
There are a few points that produce monsters .
Examples #1
The sample input #1
5 1 0
3 3
Sample output #1
12
Tips
Data assurance , 1 ≤ n ≤ 100 1 \le n \le 100 1≤n≤100, 1 ≤ m + k ≤ 25 1 \leq m+k \leq 25 1≤m+k≤25, 1 ≤ m ≤ 25 1 \leq m \leq 25 1≤m≤25, 0 ≤ k ≤ 5 0 \leq k \leq 5 0≤k≤5.
Ideas : It's a simulation problem .
At the input point 5*5 Within the scope of , Take the input point as the center point , If it is fluorite, it will be illuminated , If it is a torch, it is the sum of the absolute values of the coordinates <=2 The position of is illuminated .
And these points should be in 1 To n Between , Array cannot be out of bounds .

#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int a[101][101]={
0},n;
bool Init(int x,int y){
return x<=0||y<=0||x>n||y>n ? false : true;
}
int main(){
cin>>n;
int m,k,x1,y1,he=0;
cin>>m>>k;
for(int i=1;i<=m+k;++i){
cin>>x1>>y1;
for(int x=-2;x<=2;++x){
for(int y=-2;y<=2;++y){
if((i>m||abs(x)+abs(y)<=2)&&Init(x+x1,y+y1))
a[x+x1][y+y1]++;
}
}
}
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j)
he+=(a[i][j]==0);
}
cout<<he<<endl;
return 0;
}
边栏推荐
猜你喜欢

Nature microbiology | Bacillus subtilis biofilm promotes melon growth and disease resistance

It's decided. There are 93 open source tasks in 6 fields. Alibaba open source tutor will take you to participate in the open source summer 2022 of the Chinese Academy of Sciences

阿里达摩院TableQA技术让表格说话

PICASSO,一个高效的搜推广稀疏训练解决方案

Leetcode48. 旋转图像

2022 G3 boiler water treatment examination question bank and simulation examination

2022 latest Tianjin Construction Safety Officer simulation question bank and answers

Leetcode 49. 字母异位词分组

module ‘sklearn. datasets‘ has no attribute ‘fetch_ mldata‘

STM32——定时器中断实验
随机推荐
log4j日志配置
pycuda 安装完毕,验证步骤
Pay equal attention to quality and efficiency, test left shift power block storage technology research and development
Leetcode 49. 字母异位词分组
The art of code annotation. Does excellent code really need no annotation?
监听拖拽事件,第一次拖拽得不到上传的文件内容,第二次以后就能正常得到上传的文件内容
JD finance, are you bad, or are you cutting too much??
Huawei image xmage: seek all the images in the world, and finally see the Bodhi Heart
QT4: develop "work diary" from scratch (1) -worklog project
Bean的生命周期详解
输入一个url全过程详解
协作进程【简单总结】
Package C language files into exe executable programs
[基础服务] [数据库] MySQL 主从复制部署与配置
2022 simulated 100 questions and simulated examination for the main principals of hazardous chemical business units
[product people Wei Peng] 13 design websites necessary for product people in 2022 (version 1.0)
PICASSO,一个高效的搜推广稀疏训练解决方案
C#网络应用编程,实验七: 异步编程练习
走不下去恶补基础呢--C#线程开发输出字符串程序
Unity game file is large, how to reduce the game file