啊不是我哪错了啊

P11228 [CSP-J 2024] 地图探险

study_Zzz @ 2025-01-10 16:47:20

#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int t, n, m, k, x, y, d, ans;
int dx[4] = {0, 1, 0, -1};/*********/
int dy[4] = {1, 0, -1, 0};/*********/
char mp[N][N];
int vis[N][N];
int main() {
    cin >> t;
    while(t--) {
        ans = 1;
        cin >> n >> m >> k;
        cin >> x >> y >> d;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) cin >> mp[i][j];
        }
        memset(vis, 0, sizeof(vis));
        vis[x][y] = 1;
        while(k--) {
            int nx = x + dx[d];
            int ny = y + dy[d];
            if (nx >= 1 && nx <= n && ny >= 1 && ny <= m && mp[x][y] == '.') {
                x = nx;
                y = ny;
                if (vis[x][y] == 0) {
                    ans++;
                    vis[x][y] = 1;
                }
            } else {
                d = (d + 1) % 4;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

by study_Zzz @ 2025-01-10 16:47:43

dalao求助啊


by oliver326 @ 2025-01-10 17:19:01

第 23 行,你盯着看一分钟……


by oliver326 @ 2025-01-10 17:24:33

            if (nx >= 1 && nx <= n && ny >= 1 && ny <= m && mp[nx][ny] == '.') {

by study_Zzz @ 2025-01-10 19:04:35

噢噢噢噢噢噢噢噢噢噢噢噢噢噢噢噢噢噢噢


by study_Zzz @ 2025-01-10 19:04:59

谢谢大佬


|