当前位置:网站首页>One question per day, a classic simulation question
One question per day, a classic simulation question
2022-06-25 14:50:00 【䨁 逦】
Background
The first party of junior high school should know ......
Title Description
Say one day linyorson stay “ My world ” Opened one n \times nn×n(n \le 100n≤100) Matrix of , Now he has mm A torch and kk A fluorite , We separate (x_1, y_1) \sim (x_m, y_m)(x1,y1)∼(xm,ym) and (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 + 1m+k+1 That's ok .
First act n, m, kn,m,k.
The first 22 To the first m + 1m+1 OK, the positions of the torches x_i, y_ixi,yi.
The first m + 2m+2 To the first m + k + 1m+k+1 The lines are the positions of fluorite o_i, p_ioi,pi.
notes : Maybe no fluorite , But there must be a torch .
All data is guaranteed in int Within the scope of .
Output format
There are a few points that produce monsters .
I/o sample
Input #1 Copy
5 1 0 3 3
Output #1 Copy
12
Code section , Meter printing plus simulation
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n=0,m=0,k=0;
scanf("%d %d %d",&n,&m,&k);
int a[n+5][n+5]={0};
while(m--)
{
int x=0,y=0;
scanf("%d %d",&x,&y);
a[x-2][y]=1; a[x-1][y]=1; a[x][y]=1; a[x+1][y]=1;a[x+2][y]=1;
a[x][y-2]=1; a[x][y-1]=1;a[x][y+1]=1;a[x][y+2]=1;
a[x-1][y-1]=1; a[x-1][y+1]=1; a[x+1][y-1]=1; a[x+1][y+1]=1;
}
while(k--)
{
int x=0,y=0;
scanf("%d %d",&x,&y);
for(int i=x-2;i<=x+2;i++)
{
for(int j=y-2;j<=y+2;j++)
{
a[i][j]=1;
}
}
}
int all=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j]==0)
all++;
}
}
printf("%d\n",all);
return 0;
}
边栏推荐
- [deep learning] multi task learning of multiple datasets data sets missing labels
- 挖财是正规的吗?股票开户安全吗?
- NBD Network Block Device
- Where is it safe to open an account for buying funds? Ask for guidance
- Async await to achieve sleep waiting effect
- How to cut the size of a moving picture? Try this online photo cropping tool
- In 2022, the score line of Guangdong college entrance examination was released, and several families were happy and several worried
- Haven't you understood the microservice data architecture transaction management +acid+ consistency +cap+base theory? After reading it, you can completely solve your doubts
- 【HBZ分享】LockSupport的使用
- 成员变量与局部变量的区别
猜你喜欢

Sequential programming 1

从408改考自主命题,211贵州大学考研改考

To make pytorch faster, you need to master these 17 methods

Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement

Haven't you understood the microservice data architecture transaction management +acid+ consistency +cap+base theory? After reading it, you can completely solve your doubts

分享自己平时使用的socket多客户端通信的代码技术点和软件使用

15 -- 最接近原点的 K 个点

TSDB在民机行业中的应用

ffmpeg protocol concat 进行ts流合并视频的时间戳计算及其音画同步方式一点浅析

Build a minimalist gb28181 gatekeeper and gateway server, establish AI reasoning and 3D service scenarios, and then open source code (I)
随机推荐
The best screenshot tool in the world, color absorption tool snipaste
Stream竟然还有应用进阶学习?作为程序员的你知道吗
Share the code technology points and software usage of socket multi client communication
How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
Dmsetup command
Using Sphinx to automatically generate API documents from py source files
【Try to Hack】vulnhub DC1
JS to verify whether the string is a regular expression
dev/mapper的解释
Supplementary inheritance and strict mode
JS get the height and width corresponding to the box model (window.getcomputedstyle, dom.getboundingclientrect)
QT file reading -qfile
Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术
The best time to buy and sell stocks
Ideal L9 in the eyes of the post-90s: the simplest product philosophy, creating the most popular products
Output 0 ~ n digits and output multiple times
QT opens the print dialog box in a text editor
New good friend Pinia, leading the new era of state management
[untitled] the CMD command window displays' NPM 'which is not an internal or external command
JS component