1 条题解

  • 0
    @ 2025-10-8 17:01:07
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1010;
    int dx[]={0,1,0,-1};
    int dy[]={1,0,-1,0}; 
    char mp[N][N];
    bool vis[N][N];
    int main(){
    	ios::sync_with_stdio(false);
    	int t;cin>>t;
    	while(t--)
    	{
    		int n,m,k,x,y,d;cin>>n>>m>>k>>x>>y>>d;
    		memset(mp,0,sizeof mp);
    		for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>mp[i][j];
    		
    		int ans=1;
    		memset(vis,0,sizeof vis);vis[x][y]=1;
    		while(k--)
    		{
    			int tx=x+dx[d],ty=y+dy[d];
    			if(mp[tx][ty]=='.')
    			{
    				if(!vis[tx][ty])ans++,vis[tx][ty]=1;
    				x=tx,y=ty;
    			}
    			else d=(d+1)%4;
    		}
    		cout<<ans<<endl;
    	}
    	return 0;
    }
    
    • 1

    信息

    ID
    2364
    时间
    1000ms
    内存
    512MiB
    难度
    7
    标签
    递交数
    132
    已通过
    29
    上传者