QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#752833 | #9560. Judgement | ucup-team3555# | WA | 0ms | 3720kb | C++20 | 1.6kb | 2024-11-16 10:03:21 | 2024-11-16 10:03:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=503;
int n,m,sx,sy,tx,ty,d[N][2];
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 NO(){cout<<"NO"<<endl;}
void YES(){cout<<"YES"<<endl;}
void Solve()
{
cin>>n>>m>>sx>>sy>>tx>>ty;
for(int i=1;i<=max(n,m)+1;i++)d[i][0]=d[i][1]=0;
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>ch[i][j];
for(int i=1;i<=max(n,m)+1;i++)for(int j=1;j<=max(n,m)+1;j++)vis1[i][j]=vis2[i][j]=0;
if(ch[sx][sy]!='R'||ch[tx][ty]!='B'){cout<<"NO"<<endl;return;}
if(m==1)
{
for(int i=1;i<=n;i++)ch[1][i]=ch[i][1];
swap(n,m);
}
if(n==1)
{
for(int i=1;i<=m;i++)
{
d[i][0]=d[i-1][0];d[i][1]=d[i-1][1];
if(ch[1][i]=='R')d[i][0]++;
if(ch[1][i]=='B')d[i][1]++;
}
for(int i=1;i<=m;i++)
{
if(ch[1][i]=='R'&&d[i-1][1]&&d[m][1]-d[i][1])return NO();
if(ch[1][i]=='B'&&d[i-1][0]&&d[m][0]-d[i][0])return NO();
}
}
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])return NO();
if(ch[i][j]=='B'&&!vis2[i][j])return NO();
}
return YES();
}
int main()
{
int T;cin>>T;
while(T--)Solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3720kb
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]