QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#704733#7733. Cool, It’s Yesterday Four Times MoreSUNCHAOYIRE 16ms101960kbC++143.4kb2024-11-02 20:49:282024-11-02 20:49:28

Judging History

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

  • [2024-11-02 20:49:28]
  • 评测
  • 测评结果:RE
  • 用时:16ms
  • 内存:101960kb
  • [2024-11-02 20:49:28]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdlib.h>
#include<queue>
#include<ctime>
#include<map>
#include<set>
#include<unordered_map>
#include <bits/stdc++.h>
const double down = 0.9997;
const int N = 1005;
const int M = 200005;
const double pp = 0.00000001;
const int mod = 1000000007;
using namespace std;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
inline void write(int x){
    if(x<0) putchar('-'), x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n,m,t,siz,ans;
char c[N][N];
int mp[N][N];
bool vis[N<<1][N<<1];
vector<int > p[N<<1][N<<1];
bool cp[N][N];
vector<pair<int ,int > > l;
int tx[] = {1,0,-1,0};
int ty[] = {0,1,0,-1};
void dfs(int nx,int ny,int px,int py,int id)
{
	p[px][py].push_back(id);
//	cout<<"!"<<endl;
	vis[nx][ny] = true;
	for(int i=0;i<4;i++)
	{
		int x = nx + tx[i] , y = ny + ty[i];
		if((!x)||(!y)||(x>n)||(y>m))	continue;
		if(!mp[x][y])	continue;
		if(vis[x][y])	continue;
		dfs(x,y,px+tx[i],py+ty[i],id);
	}
}
void clear()
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			mp[i][j] = 0;
		}
	}
	for(int nx=1000-n;nx<=1000+n;nx++)
		for(int ny=1000-m;ny<=1000+m;ny++)
		{
			vector<int>tmp;
			swap(p[nx][ny],tmp);
		}
//	p.clear();
//	p.shrink_to_fit();//wrong
	vector<pair<int,int> >tmp;
	swap(l,tmp);
	ans = 0;
}
int main()
{
//	freopen("A.in","r",stdin);
	//freopen(".out","w",stdout);
	//srand(time(0));
	t = read();
	while(t--)
	{
//		cout<<"!!";
		n = read() , m = read();
//		if(n>800||m>800)	break;
		for(int i=1;i<=n;i++)	scanf("%s",c[i]+1);
//		cout<<"!!";
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(c[i][j]=='.')
				{
					mp[i][j] = 1;
					l.push_back(make_pair(i,j));
				}
			}
		}
//		cout<<"!!";
		siz = l.size();
//		cout<<siz<<endl;
//		cout<<"!!";
		for(int i=0;i<siz;i++)
		{
			for(int j=0;j<siz;j++)
				cp[i][j] = false;
			cp[i][i] = true;
		}
//		cout<<"!!";
		for(int i=0;i<siz;i++)
		{
			dfs(l[i].first,l[i].second,1000,1000,i);
			for(int ix=1;ix<=n;ix++)
				for(int iy=1;iy<=m;iy++)
					vis[ix][iy] = false;
		}
//		cout<<"??"<<endl;
		for(int nx=1000-n;nx<=1000+n;nx++)
		{
			for(int ny=1000-m;ny<=1000+m;ny++)
			{
//				for(int to=0;to<4;to++)
//				{
//				int nx = 1000 + i * tx[to] , ny = 1000 + j * ty[to];
				int len = p[nx][ny].size() , po = 0;
				if(!len)	continue;
//				cout<<nx<<" "<<ny<<":";
//				for(auto qq:p[nx][ny])	cout<<qq<<' ';
//				cout<<endl;
				vector<int > lose;
				for(int k=0;k<siz;k++)
				{
					if(k==p[nx][ny][po])
					{
						po++;
					}
					else
					{
						lose.push_back(k);
					}
				}
//					cout<<"?!";
				for(int k0=0;k0<len;k0++)
				{
					for(int k1=0;k1<siz-len;k1++)
					{
//							assert (lose.size() > k1);
						cp[p[nx][ny][k0]][lose[k1]] = true;
					}
				}
				vector<int>tmp;
				swap(lose,tmp);
//				}
			}
		}
		for(int i=0;i<siz;i++)
		{
			bool pd = true;
			for(int j=0;j<siz;j++)
			{
				if(!cp[i][j])
				{
					pd = false;
				}
//				cout<<cp[i][j];
			}
//			cout<<endl;
			if(pd)	ans++;
		}
		write(ans);
		putchar('\n');
		clear();
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 16ms
memory: 101960kb

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: 0
Accepted
time: 12ms
memory: 101956kb

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
7
9
4
4
0
6
5
2
0
1
6
4
5
2
0
0
5
3
3
1
4
1
0
7
5
2
3
7
3
0
6
2
2
2
0
4
6
6
3
3
2
3
5
2
1
0
3
3
4
4
2
2
0
7
6
4
8
5
3
2
5
2
1
2
1
4
0
0
2
5
1
4
6
6
1
6
2
2
3
4
5
2
1
0
1
9
3
4
11
0
3
2
1
0
0
4
3
1
4
3
8
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
5
0
16
4
3
2
6
0
8
3
3
1...

result:

ok 200 lines

Test #3:

score: -100
Runtime Error

input:

50
10 9
OOOO.O...
O...O.OOO
.....O...
..OO..O.O
...O..O.O
..OOO..O.
..OOO...O
.OO.O..OO
.O.O.OO..
.O..O.O.O
10 10
.O.OOO.OO.
...OOOOOOO
...O.O..O.
.O.O..O...
.O.O.OO..O
..OO.O..OO
O....O..OO
OO...OOOOO
OO.OO.O..O
.O.O.OOOOO
10 8
O..OOO.O
O.OOOO..
O..OO.OO
OO..OO..
.OOO..O.
.OO.OO.O
OOO..OO.
..O..OO....

output:


result: