比赛样例全过,为什只有50pts
查看原帖
比赛样例全过,为什只有50pts
1228260
LamineYamal楼主2024/10/26 18:08
#include<bits/stdc++.h>
#define endl "\n"
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N=1e3+5;
int T,n,m,k,x,y,d,cnt,arr[N][N],maps[N][N];
void walk(int nx,int ny,int nd)
{
	if(nd==0)
	{
		ny+=1;
	}
	if(nd==1)
	{
		nx+=1;
	}
	if(nd==2)
	{
		ny-=1;
	}
	if(nd==3)
	{
		nx-=1;
	}
	if(nx>n||nx<1||ny>m||ny<1||arr[nx][ny]==2)
	{
		d=(nd+1)%4;
		return ;
	}
	else
	{
		if(maps[nx][ny]==0)
		{
			cnt++;
			maps[nx][ny]=1;
		}
		x=nx;
		y=ny;
	}
	return ;
}
int main()
{
	fast;
	cin>>T;
	while(T--)
	{
		memset(maps,0,sizeof(maps));
		cnt=1;
		cin>>n>>m>>k>>x>>y>>d;
		for(int i=1;i<=n;i++)
		{
			string a;
			cin>>a;
			for(int j=0;j<m;j++)
			{
				if(a[j]=='.')
				{
					arr[i][j+1]=1;
				}
				else
				{
					arr[i][j+1]=2;
				}
			}
		}
		for(int i=1;i<=k;i++)
		{
			walk(x,y,d);
		}
		cout<<cnt<<endl;
	}
	return 0;
}
2024/10/26 18:08
加载中...