QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87034#3002. Busy BoardBirdWA 14ms5564kbC++141.6kb2023-03-11 16:27:252023-03-11 16:27:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-11 16:27:26]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:5564kb
  • [2023-03-11 16:27:25]
  • 提交

answer

#include<bits/stdc++.h>
#define N 1000
using namespace std;
int n,m,cntr[N+5],cntc[N+5];
char st[N+5][N+5],ed[N+5][N+5];
bool visr[N+5],visc[N+5];
inline bool check()
{
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(st[i][j]!=ed[i][j]) return 0;
	return 1;
}
queue<pair<int,int>> q;
inline void check_node(int x,int y)
{
	if(ed[x][y]=='O') return;
	int col=ed[x][y]=='X';
	if(cntr[x]==col && cntc[y]==col) q.push({x,y});
}
inline void checkr(int x) {for(int y=1;y<=m;++y) check_node(x,y);}
inline void checkc(int y) {for(int x=1;x<=n;++x) check_node(x,y);}
inline void del_node(int x,int y)
{
	if(ed[x][y]!='X') return;
	if((--cntr[x])<=1) checkr(x);
	if((--cntc[y])<=1) checkc(y);
}
inline void delr(int x) {for(int y=1;y<=m;++y) del_node(x,y),ed[x][y]='?';}
inline void delc(int y) {for(int x=1;x<=n;++x) del_node(x,y),ed[x][y]='?';}
inline bool check_ans()
{
	for(int i=1;i<=n;++i) if(!visr[i])
		for(int j=1;j<=m;++j) if(!visc[j])
			if(st[i][j]!=ed[i][j]) return 0;
	for(int i=1;i<=n;++i) if(visr[i])
		for(int j=1;j<=m;++j) if(visc[j])
			if(st[i][j]=='O') return 1;
	return 0;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
	for(int i=1;i<=n;++i) scanf("%s",ed[i]+1);
	if(check()) return puts("1"),0;
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j)
		if(ed[i][j]=='X') ++cntr[i],++cntc[j];
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) check_node(i,j);
	while(!q.empty())
	{
		int x=q.front().first,y=q.front().second;q.pop();
		if(!visr[x]) visr[x]=1,delr(x);
		if(!visc[y]) visc[y]=1,delc(y);
	}
	printf("%d\n",check_ans());
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 12ms
memory: 5148kb

input:

769 998
OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #2:

score: 0
Accepted
time: 14ms
memory: 5564kb

input:

977 998
OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #3:

score: -100
Wrong Answer
time: 9ms
memory: 5444kb

input:

941 973
XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:

0

result:

wrong answer expected 1, found 0