10分,求助(考场过了,回家WA)

P11228 [CSP-J 2024] 地图探险

zzhengxi @ 2024-10-26 21:56:17

代码来了

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

bool v[1010][1010];
char mp[1010][1010];
int ne[4][2] = {{0,1},{1,0},{0,-1},{-1,0}};
int main(){
    int t,n,m,k;
    cin >> t;
    while(t --){
        cin >> n >> m >> k;
        int x,y,d;
        cin >> x >> y >> d;
        for(int i = 1 ; i <= n ; i ++)
            for(int j = 1 ; j <= m ; j ++)
                cin >> mp[i][j];
        v[x][y] = true;
        for(int i = 1 ; i <= k ; i ++){
            //cout << i << "." << x << ' ' << y << ' ' << d << '\n';
            int xx = x + ne[d][0];
            int yy = y + ne[d][1];
            //cout << xx << ' ' << yy << '\n';
            if(xx >= 1 && yy >= 1 && xx <= n && yy <= m && mp[xx][yy] == '.'){
                x = xx,y = yy;
                v[xx][yy] = true;
                //cout << "A";
            }
            else 
            {
            d = (d + 1) % 4;
                //cout << "A";
            }
        }
        int cnt = 0;
        for(int i = 1 ; i <= n ; i ++)
            for(int j = 1 ; j <= m ; j ++)
                if(v[i][j] == true)
                    cnt ++;
        cout << cnt << '\n';

    }
    return 0;
}

求助


by linrun0504 @ 2024-10-26 21:58:18

@zzhengxi

多组样例的初始化设了吗!!!


by zzhengxi @ 2024-10-26 22:08:37

谢谢大佬,忘加了


by zzhengxi @ 2024-10-26 22:13:53

A了


|