QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#52063#2213. KnightConstant#WA 5ms8252kbC++14963b2022-10-04 10:15:562022-10-04 10:15:56

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-04 10:15:56]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:8252kb
  • [2022-10-04 10:15:56]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define N 1005
using namespace std;
int vis[N][N],n,m,r,c,ax,ay,bx,by;
char s[N][N];
struct node
{
	int x,y;
};
queue<node>q;
int main() 
{
	scanf("%d%d%d%d",&n,&m,&r,&c);
	memset(vis,-1,sizeof(vis));
	int nt[8][2]={{r,c},{-r,c},{r,-c},{-r,-c},{c,r},{c,-r},{-c,r},{-c,-r}};
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
		{
			if(s[i][j]=='A') ax=i,ay=j;
			if(s[i][j]=='B') bx=i,by=j;
		}
	}
	q.push((node){ax,ay});
	vis[ax][ay]=1;
	while(!q.empty())
	{
		node u=q.front();
		q.pop();
		for(int k=0;k<=7;k++)
		{
			int mx=u.x+nt[k][0],my=u.y+nt[k][1];
			if(mx<1||my<1||mx>n||my>m) continue;
			if(s[mx][my]=='@'||vis[mx][my]) continue;
			vis[mx][my]=(vis[u.x][u.y]^1);
			q.push((node){mx,my});
		}
	}
	if(vis[bx][by]==-1)
	{
		printf("Alice");
		return 0;
	}
	if(vis[ax][ay]==vis[bx][by]) printf("Alice");
	else printf("Bob");
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 8252kb