@[Lucky_90](/user/1261339) 你需要将 $x$ 坐标和 $y$ 坐标偏移 $1$ 格。
以下是我的火把照明图:
```
2 2 2 2 2 2 1 1
1 1 1 1 1 1 1 0
2 2 2 2 2 2 1 1
1 1 1 1 1 1 1 0
2 2 2 2 2 2 1 1
1 1 1 1 1 1 1 1
2 1 2 1 2 1 2 1
1 1 1 1 1 1 1 1
2
```
本蒟不会 Java,但是我可以提供我的 c++ 代码:
```cpp
#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
bool a[104][104];
int n,m,k,x,y,sum = 0;
void torch(int x,int y){
a[x][y-2] = true;
a[x-1][y-1] = true;
a[x][y-1] = true;
a[x+1][y-1] = true;
a[x-2][y] = true;
a[x-1][y] = true;
a[x][y] = true;
a[x+1][y] = true;
a[x+2][y] = true;
a[x-1][y+1] = true;
a[x][y+1] = true;
a[x+1][y+1] = true;
a[x][y+2] = true;
pq.push(make_pair(x,y));
}
void light_stone(int x,int y){
a[x-2][y-2] = true;
a[x-1][y-2] = true;
a[x][y-2] = true;
a[x+1][y-2] = true;
a[x+2][y-2] = true;
a[x-2][y-1] = true;
a[x-1][y-1] = true;
a[x][y-1] = true;
a[x+1][y-1] = true;
a[x+2][y-1] = true;
a[x-2][y] = true;
a[x-1][y] = true;
a[x][y] = true;
a[x+1][y] = true;
a[x+2][y] = true;
a[x-2][y+1] = true;
a[x-1][y+1] = true;
a[x][y+1] = true;
a[x+1][y+1] = true;
a[x+2][y+1] = true;
a[x-2][y+2] = true;
a[x-1][y+2] = true;
a[x][y+2] = true;
a[x+1][y+2] = true;
a[x+2][y+2] = true;
pq.push(make_pair(x,y));
}
int main(){
ios::sync_with_stdio(0),cin,tie(0),cout.tie(0);
cin >> n >> m >> k;
for(int i = 0;i < m;i++){
cin >> x >> y;
torch(x+1,y+1);
}
for(int i = 0;i < k;i++){
cin >> x >> y;
light_stone(x+1,y+1);
}
for(int i = 2;i < n+2;i++){
for(int j = 2;j < n+2;j++){
if(make_pair(i,j) == pq.top()){
cout << "2 ";
pq.pop();
}
else
cout << a[i][j] << ' ';
if(!a[i][j])
sum++;
}
cout << '\n';
}
cout << sum;
return 0;
}
```
该代码会输出火把照明图,请勿拿此代码提交!
by liuli688 @ 2024-02-08 20:21:28
@[Lucky_90](/user/1261339) 本题中 $x = 1,y = 1$ 指地图左上角。
by liuli688 @ 2024-02-08 20:32:21
@[liuli688](/user/1014842) 原来如此!感谢大大!我去调试一下!万分感恩!!
by Lucky_90 @ 2024-02-09 17:57:43
@[liuli688](/user/1014842) 对了,刚刚忘记说了,顺祝新春快乐!
by Lucky_90 @ 2024-02-09 17:58:08
@[Lucky_90](/user/1261339) 谢谢!
by liuli688 @ 2024-02-09 21:25:34