﻿ P1789 【Mc生存】插火把 - 鸿网互联

# P1789 【Mc生存】插火把

## 题目描述

P.S.火把的照亮范围是：

``````|暗|暗| 光 |暗|暗|
|暗|光| 光 |光|暗|
|光|光|火把|光|光|
|暗|光| 光 |光|暗|
|暗|暗| 光 |暗|暗|``````

``````|光|光| 光 |光|光|
|光|光| 光 |光|光|
|光|光|萤石|光|光|
|光|光| 光 |光|光|``````

|光|光| 光 |光|光|

## 输入输出样例

```5 1 0
3 3```

`12`

``` 1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 #include<map>
6 #include<algorithm>
7 #include<map>
8 #define LL long long int
9 using namespace std;
10 const int MAXN=88000;
12 {
13     char c=getchar();n=0;bool flag=0;
14     while(c<'0'||c>'9')    c=='-'?flag=1,c=getchar():c=getchar();
15     while(c>='0'&&c<='9')    n=n*10+c-48,c=getchar();flag==1?n=-n:n=n;
16 }
17 map<pair<int,int>,bool>mp;
18 int main()
19 {
20     int n,a,b;
22     for(int i=1;i<=a;i++)
23     {
24         int x,y;
26         mp[make_pair(x,y)]=1;
27         mp[make_pair(x-1,y)]=1;mp[make_pair(x-2,y)]=1;mp[make_pair(x+1,y)]=1;mp[make_pair(x+2,y)]=1;
28         mp[make_pair(x,y-1)]=1;mp[make_pair(x,y-2)]=1;mp[make_pair(x,y+1)]=1;mp[make_pair(x,y+2)]=1;
29         mp[make_pair(x-1,y-1)]=1;mp[make_pair(x+1,y-1)]=1;mp[make_pair(x-1,y+1)]=1;mp[make_pair(x+1,y+1)]=1;
30     }
31     for(int i=1;i<=b;i++)
32     {
33         int x,y;
35         mp[make_pair(x,y)]=1;
36         mp[make_pair(x-1,y)]=1;mp[make_pair(x-2,y)]=1;mp[make_pair(x+1,y)]=1;mp[make_pair(x+2,y)]=1;
37         mp[make_pair(x,y-1)]=1;mp[make_pair(x,y-2)]=1;mp[make_pair(x,y+1)]=1;mp[make_pair(x,y+2)]=1;
38         mp[make_pair(x-1,y-1)]=1;mp[make_pair(x+1,y-1)]=1;mp[make_pair(x-1,y+1)]=1;mp[make_pair(x+1,y+1)]=1;
39         mp[make_pair(x-2,y-1)]=1;mp[make_pair(x-1,y-2)]=1;mp[make_pair(x-2,y-2)]=1;
40         mp[make_pair(x-1,y+2)]=1;mp[make_pair(x-2,y+1)]=1;mp[make_pair(x-2,y+2)]=1;
41         mp[make_pair(x+1,y-2)]=1;mp[make_pair(x+2,y-1)]=1;mp[make_pair(x+2,y-2)]=1;
42         mp[make_pair(x+1,y+2)]=1;mp[make_pair(x+2,y+1)]=1;mp[make_pair(x+2,y+2)]=1;
43     }
44     int ans=0;
45     for(int i=1;i<=n;i++)
46         for(int j=1;j<=n;j++)
47             if(mp[make_pair(i,j)]==0)
48                 ans++;
49     printf("%d",ans);
50     return 0;
51 }```

<