文章

11

粉丝

0

获赞

9

访问

522

头像
生化武器2 题解:
P1124
发布于2026年2月1日 12:12
阅读数 91

#include <bits/stdc++.h>
using namespace std;

const int N = 105;
const int INF = 1e9;

char mp[N][N];
int dx[4] = {-1, 1, 0, 0};   // 最后一个 0,0 表示“原地不动”
int dy[4] = {0, 0, -1, 1};

bool bfs_(int n, int m, int t)
{
    int gi = -1, gj = -1;
    int si = -1, sj = -1;

    // 找 G 和 S
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(mp[i][j] == 'G') { gi = i; gj = j; }
            if(mp[i][j] == 'S') { si = i; sj = j; }
        }
    }

    queue<pair<int, int>> g1, s1;
    g1.push({gi, gj}); s1.push({si, sj});
    while(t --)
    {
        int cnt1 = g1.size();
      ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发