QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#658126#7733. Cool, It’s Yesterday Four Times MoreYoralenWA 1ms3924kbC++141.7kb2024-10-19 16:12:382024-10-19 16:12:40

Judging History

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

  • [2024-10-19 16:12:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3924kb
  • [2024-10-19 16:12:38]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define int long long
const int N=1005;
char a[N][N];
int n,m,mp[N][N],tot,vis[N][N],ban[N],T;
struct node{int x,y;}q[N*4],st[N*4];
int dx[5]={0,0,1,0,-1},dy[5]={0,1,0,-1,0};
vector<node>F[N];
void BFS(int rx,int ry){
	int l=1,r=0,mix=rx,miy=ry,tp=0,i;
	q[++r]=(node){rx,ry};
	vis[rx][ry]=1;st[++tp]=(node){rx,ry};
	while(l<=r){
		node u=q[l];l++;
		for(i=1;i<=4;i++){
			int tx=u.x+dx[i],ty=u.y+dy[i];
			if(1<=tx&&tx<=n&&1<=ty&&ty<=m&&!vis[tx][ty]&&a[tx][ty]=='.'){
				q[++r]=(node){tx,ty};
				vis[tx][ty]=1;st[++tp]=(node){tx,ty};
				mix=min(mix,tx),miy=min(miy,ty);
			}
		}
	}
	tot++;
	for(i=1;i<=tp;i++)F[tot].push_back((node){st[i].x-mix,st[i].y-miy});
//	for(node u:F[tot])printf("%d %d\n",u.x,u.y);
//	putchar('\n');
}
void Deal(int I,int J){
	for(node u:F[I])mp[u.x][u.y]++;
	for(node u:F[J])mp[u.x][u.y]++;
	int num=0,nI=F[I].size(),nJ=F[J].size();
	for(node u:F[I]){
		if(mp[u.x][u.y]==2)num++;
	}
	if(nI==nJ){
		if(num==nI)ban[I]=ban[J]=1;
	}
	else{
		if(nI<nJ&&num==nI)ban[I]=1;
		if(nI>nJ&&num==nJ)ban[J]=1;
	}
	for(node u:F[I])mp[u.x][u.y]=0;
	for(node u:F[J])mp[u.x][u.y]=0;
}
signed main(){
	int i,j,ans=0;
	scanf("%d",&T);
	while(T--){
		scanf("%d%d",&n,&m);
		for(i=1;i<=n;i++)scanf("%s",a[i]+1);
		for(i=1;i<=n;i++){
			for(j=1;j<=m;j++)vis[i][j]=0;
		}
		for(i=1;i<=n;i++){
			for(j=1;j<=m;j++){
				if(a[i][j]=='.'&&!vis[i][j]){BFS(i,j);}
			}
		}
		for(i=1;i<=tot;i++){
			for(j=i+1;j<=tot;j++){
				if(!ban[i]||!ban[j])Deal(i,j);
			}
		}
		for(i=1;i<=tot;i++){
		//	printf("%d,",ban[i]);
			if(!ban[i])ans+=F[i].size();
			F[i].clear();ban[i]=0;
		}
	//	putchar('\n');
		printf("%d\n",ans);tot=0;ans=0;
	}
}

详细

Test #1:

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

input:

4
2 5
.OO..
O..O.
1 3
O.O
1 3
.O.
2 3
OOO
OOO

output:

3
1
0
0

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3868kb

input:

200
2 4
OOO.
OO..
2 3
OOO
.O.
3 3
O.O
OOO
OO.
4 1
.
.
O
O
1 2
.O
1 1
.
2 5
.OO..
.O.O.
2 1
O
O
1 1
O
1 3
.OO
5 1
O
O
.
O
.
5 2
O.
..
O.
.O
..
5 3
...
...
.OO
..O
OOO
3 5
..O.O
.O.O.
.OO.O
5 2
.O
OO
O.
O.
..
2 1
O
O
3 5
.O.OO
O...O
..OO.
1 5
.....
5 1
O
.
O
.
.
5 3
OOO
OO.
.OO
OO.
O.O
2 1
O
.
5 2
O.
...

output:

3
0
0
2
1
1
5
0
0
1
0
7
9
4
5
0
6
5
2
0
1
6
4
5
2
0
0
5
3
3
1
4
1
0
7
5
2
3
9
3
0
6
2
2
2
0
4
6
6
5
5
2
5
5
2
1
0
4
3
5
4
2
2
0
7
7
4
11
5
3
2
5
2
1
2
1
4
0
0
2
5
1
4
6
9
1
6
2
2
5
4
5
2
1
0
1
9
3
4
11
0
3
2
1
0
0
4
3
1
4
3
12
3
0
3
6
2
5
1
3
3
4
0
2
11
2
2
4
0
4
4
6
2
1
2
3
0
7
0
17
6
3
2
7
0
8
3
3...

result:

wrong answer 7th lines differ - expected: '3', found: '5'