QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#88126#3251. 数正方体DoubleQingWA 3ms6628kbC++111.8kb2023-03-15 11:25:462023-03-15 11:25:49

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 11:25:49]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6628kb
  • [2023-03-15 11:25:46]
  • 提交

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=10000,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)
{
	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;
		if(mp[x][y-1]=='-'&&mp[x+1][y-1]=='/')
			cnt++;
		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});
			
		}
	}
	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++)
		{
			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});
		}
		bool f=1;
		for(int j=0;j<4;j++)
			if(mp[x+cx[j]][y+cy[j]]=='.')
			{
				f=0;
				break;
			}
		if(f&&mp[x-1][y]!='|'&&mp[x+1][y]=='|')
			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
Wrong Answer
time: 3ms
memory: 6628kb

input:

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

output:

84474

result:

wrong answer 1st lines differ - expected: '84826', found: '84474'