QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#527586#7733. Cool, It’s Yesterday Four Times MoreStelorWA 3ms3732kbC++201.6kb2024-08-22 17:22:042024-08-22 17:22:04

Judging History

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

  • [2024-08-22 17:22:04]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3732kb
  • [2024-08-22 17:22:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define PII pair<int,int>
#define PIIII pair<PII,PII>
const int N=1e3+100;
int n,m,ans,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
char s[N][N];
map<PIIII,int> mp;
bool fail(int x,int y)
{
	if(x>n||x<1||y>m||y<1||s[x][y]!='.') return true;
	return false;
}
void dfs(int x,int y,int i,int j)
{
	mp[{{x,y},{i,j}}]=1;
	for(int t=0;t<4;++t)
	{
		int nx=x+dx[t],ny=y+dy[t];
		int ni=i+dx[t],nj=j+dy[t];
		if(fail(nx,ny)) continue;
		if(fail(ni,nj)) 
		{
			mp[{{x,y},{i,j}}]=2;
			mp[{{nx,ny},{ni,nj}}]=2;
			continue;
		} 
		if(!mp.count({{nx,ny},{ni,nj}}))
		{
		    dfs(nx,ny,ni,nj);
		    if(mp[{{nx,ny},{ni,nj}}]==2)
		    {
		        mp[{{x,y},{i,j}}]=2;
		    }
		}else
		{
		    if(mp[{{nx,ny},{ni,nj}}]==2)
		    mp[{{x,y},{i,j}}]=2;
		}
	}
}
void work(int x,int y)
{
	int now=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
		    if(i==x&&y==j) continue;
			if(s[i][j]=='.')
			{
				if(mp.count({{x,y},{i,j}}))
				{
					if(mp[{{x,y},{i,j}}]==2)
					now++;
					else  return;
				}
				else
				{
					dfs(x,y,i,j);
					if(mp[{{x,y},{i,j}}]==2) now++;
					else return;
				}
				
			}
		}
	}
	++ans; 
}
void solve()
{
    ans=0;
	mp.clear();
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			cin>>s[i][j];
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{

			if(s[i][j]=='.') work(i,j);
		}
	}
	cout<<ans<<endl;

}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin>>_;
	while(_--) solve();
	return 0;	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3ms
memory: 3708kb

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
3
0
0
1
0
6
7
3
4
0
4
2
2
0
1
6
3
5
2
0
0
4
3
3
1
2
1
0
6
2
2
2
6
2
0
6
2
2
2
0
3
6
3
3
2
2
2
4
2
1
0
3
3
3
4
2
2
0
6
6
2
6
4
3
2
5
2
1
2
1
2
0
0
2
3
1
3
4
6
1
6
2
2
3
4
4
2
1
0
1
6
3
4
11
0
2
2
1
0
0
2
2
1
4
2
7
3
0
3
5
2
4
1
2
3
2
0
2
10
2
2
4
0
2
4
4
2
1
2
2
0
4
0
14
4
3
2
5
0
7
2
3
1...

result:

wrong answer 12th lines differ - expected: '7', found: '6'