QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752810#9560. Judgementucup-team3555#WA 0ms3588kbC++201.1kb2024-11-16 09:54:162024-11-16 09:54:16

Judging History

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

  • [2024-11-16 09:54:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-11-16 09:54:16]
  • 提交

answer

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

typedef long long ll;
const int N=503;
int n,m,sx,sy,tx,ty;
char ch[N][N];
bool vis1[N][N],vis2[N][N];
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
bool Ok(int x,int y){return 1<=x&&x<=n&&1<=y&&y<=m&&ch[x][y]!='.';}
void Dfs1(int x,int y)
{
	if(vis1[x][y])return;
	vis1[x][y]=1;
	for(int i:{0,1,2,3})
	{
		int kx=x+dx[i],ky=y+dy[i];
		if(Ok(kx,ky)&&(kx!=tx||ky!=ty))Dfs1(kx,ky);
	}
}
void Dfs2(int x,int y)
{	
	if(vis2[x][y])return;
	vis2[x][y]=1;
	for(int i:{0,1,2,3})
	{
		int kx=x+dx[i],ky=y+dy[i];
		if(Ok(kx,ky)&&(kx!=sx||ky!=sy))Dfs2(kx,ky);
	}
}
void Solve()
{
	cin>>n>>m>>sx>>sy>>tx>>ty;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>ch[i][j],vis1[i][j]=vis2[i][j]=0;
	if(ch[sx][sy]!='R'||ch[tx][ty]!='B'){cout<<"NO"<<endl;return;}
	Dfs1(sx,sy);Dfs2(tx,ty);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
	{
		if(ch[i][j]=='R'&&!vis1[i][j]){cout<<"NO"<<endl;return;}
		if(ch[i][j]=='B'&&!vis2[i][j]){cout<<"NO"<<endl;return;}
	}
	cout<<"YES"<<endl;
}
int main()
{
	int T;cin>>T;
	while(T--)Solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

4
3 3
1 1 1 2
RBB
RRR
BBR
6 6
1 1 6 6
RRRRRR
BBBBBR
BRRRBR
BRBBBR
BRRRRR
BBBBBB
5 5
3 3 4 4
BBR.B
BBR.B
RRR.B
...BB
BBBB.
1 5
1 1 1 3
RBBBR

output:

YES
YES
NO
NO

result:

ok 4 token(s): yes count is 2, no count is 2

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3588kb

input:

18
4 4
3 3 2 2
....
.BB.
.BR.
....
7 8
5 6 3 3
..RRRRRR
..R....R
BBBBBB.R
B.B..R.R
B.RRRRRR
B....B..
BBBBBB..
5 2
3 1 3 2
B.
BR
RB
BR
.R
3 3
2 2 1 2
.BB
BRB
BBB
3 3
1 2 3 2
RRR
...
BBB
3 3
1 1 1 3
RRB
...
BRR
3 3
1 1 3 1
RRB
...
BRR
3 3
3 1 1 1
BBR
..R
RBB
3 3
2 2 2 1
.BB
BRB
.RB
1 2
1 1 1 2
RB
2 2
...

output:

YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

wrong answer expected NO, found YES [8th token]