QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#88119#3251. 数正方体DoubleQingRE 0ms0kbC++111.8kb2023-03-15 10:56:252023-03-15 10:56:29

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-15 10:56:29]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-03-15 10:56:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define PII pair<int,int>
#define x first
#define y second
const int N=100,M=2*N,mod=1e9+7;

char mp[N][N];
int n,m;
int cnt;
bool st[N][N];
int dx[]={0,2,0},dy[]={4,-2,-4};
int cx[]={0,0,1,-1},cy[]={1,-1,0,0};
int last,res;

void bfs(int sx,int sy)
{
	queue<PII> q;
	q.push({sx,sy});
	st[sx][sy]=1;
	while(q.size())
	{
		PII t=q.front();
		q.pop();
		int x=t.x,y=t.y;
		bool f=1;
		for(int i=0;i<3;i++)
		{
			int xx=x+dx[i],yy=y+dy[i];
			if(xx<1||xx>n||yy<1||yy>m||mp[xx][yy]!='+'||st[xx][yy])
				continue;
			st[xx][yy]=1;
			q.push({xx,yy});
			if(mp[xx][yy-1]=='-'&&mp[xx+1][yy-1]=='/')
				cnt++;
		}
	}
	res=last=cnt;
}

void bfs1(int sx,int sy)
{
	cnt=0;
	queue<PII> q;
	q.push({sx,sy});
	st[sx][sy]=1;
	while(q.size())
	{
		PII t=q.front();
		q.pop();
		int x=t.x,y=t.y;
		for(int i=0;i<3;i++)
		{
			bool f=1;
			int xx=x+dx[i],yy=y+dy[i];
			if(xx<1||xx>n||yy<1||yy>m||mp[xx][yy]!='+'||st[xx][yy])
				continue;
			st[xx][yy]=1;
			q.push({xx,yy});
			for(int j=0;j<4;j++)
				if(mp[x+cx[j]][y+cy[j]]=='.')
				{
					f=0;
					break;
				}
			if(f&&mp[xx-1][yy]!='|'&&!(mp[xx+1][yy]!='|'))
				cnt++;
		}
	}
	last+=cnt;
	res+=last;
}

void solve()
{
	scanf("%d %d",&n,&m);
	getchar();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			mp[i][j]=getchar();
		getchar();
	}
	for(int i=1;i<=n;i++)
	{
		bool f=0;
		for(int j=1;j<=m;j++)
			if(mp[i][j]=='+')
			{
				bfs(i,j),f=1;
				break;
			}
		if(f)
			break;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(mp[i][j]=='+'&&!st[i][j])
				bfs1(i,j);
	
	cout<<res-last<<endl;
	
	
	return;
}

signed main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0),cout.tie(0);
	
	int T=1;
	//cin>>T;
	while(T--)
		solve();
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

371 259
......................................................................+---+---+....................................................................................................................................................................................
...................................

output:


result: