QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607662#833. Cells BlockingkgqyWA 290ms219492kbC++142.2kb2024-10-03 15:43:402024-10-03 15:43:40

Judging History

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

  • [2024-10-03 15:43:40]
  • 评测
  • 测评结果:WA
  • 用时:290ms
  • 内存:219492kb
  • [2024-10-03 15:43:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int w=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) w=w*10+ch-'0',ch=getchar();
	return w;
}
inline int gc(){
	char ch=getchar();
	while(ch!='*'&&ch!='.') ch=getchar();
	return ch=='*';
}
int n,m;
int blk[3005][3005],wtn;
int tob[3005][3005],toe[3005][3005];
pair<int,int> l1[3005],l2[3005];
int gre[3005][3005];
int blu[3005][3005],sblu=1;
main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) blk[i][j]=gc(),wtn+=(blk[i][j]^1);
	tob[1][1]=blk[1][1]^1;
	for(int k=3;k<=n+m;k++){
		for(int i=1,j=k-1;j;i++,j--){
			if(i>n||j>m) continue;
			if(blk[i][j]) continue;
			tob[i][j]=tob[i-1][j]|tob[i][j-1];
		}
	}
	if(!tob[n][m]) return printf("%lld\n",max(0ll,wtn*(wtn-1)/2)),0;
	toe[n][m]=blk[n][m]^1;
	for(int k=n+m-1;k>=2;k--){
		for(int i=1,j=k-1;j;i++,j--){
			if(i>n||j>m) continue;
			if(blk[i][j]) continue;
			toe[i][j]=toe[i+1][j]|toe[i][j+1];
		}
	}
	l1[1]={1,1};
	for(int i=2;i<n+m;i++){
		int lsx=l1[i-1].first,lsy=l1[i-1].second;
		if(toe[lsx+1][lsy]) lsx++;
		else lsy++;
		l1[i]={lsx,lsy};
	}
	l2[1]={1,1};
	blu[1][1]=1;
	for(int i=2;i<n+m;i++){
		int lsx=l2[i-1].first,lsy=l2[i-1].second;
		if(toe[lsx][lsy+1]) lsy++;
		else lsx++;
		l2[i]={lsx,lsy};
		if(l1[i]==l2[i]) blu[lsx][lsy]=1,sblu++;
	}
	// for(int i=1;i<n+m;i++) printf("%d %d %d %d %d\n",i,l1[i].first,l1[i].second,l2[i].first,l2[i].second);
	int ans=sblu*(wtn-sblu)+sblu*(sblu-1)/2;
	// printf("%d\n",ans);
	for(int i=1;i<n+m;i++){
		int nx=l1[i].first,ny=l1[i].second;
		// printf("%d %d %d\n",i,nx,ny);
		if(blu[nx][ny]) continue;
		nx--,ny++;
		while(!tob[nx][ny]||!toe[nx][ny]) nx--,ny++;
		// printf("%d %d %d\n",i,nx,ny);
		if(l2[i].first==nx&&l2[i].second==ny&&!blu[nx][ny]) ans++;
		int tx=nx,ty=ny;
		for(int j=i-1;j;j--){
			if(tob[tx][ty-1]) ty--;
			else tx--;
			if(l2[j].first==tx&&l2[j].second==ty&&!blu[tx][ty]) ans++;
		}
		tx=nx,ty=ny;
		for(int j=i+1;j<=n+m;j++){
			if(tob[tx+1][ty]) tx++;
			else ty++;
			if(l2[j].first==tx&&l2[j].second==ty&&!blu[tx][ty]) ans++;
		}
	}
	printf("%lld\n",ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9908kb

input:

3 3
...
...
...

output:

17

result:

ok 1 number(s): "17"

Test #2:

score: 0
Accepted
time: 1ms
memory: 9956kb

input:

3 3
.**
.*.
...

output:

15

result:

ok 1 number(s): "15"

Test #3:

score: 0
Accepted
time: 1ms
memory: 7988kb

input:

3 4
****
....
****

output:

6

result:

ok 1 number(s): "6"

Test #4:

score: 0
Accepted
time: 1ms
memory: 7832kb

input:

5 5
*....
.*.*.
*****
*.***
..*..

output:

66

result:

ok 1 number(s): "66"

Test #5:

score: 0
Accepted
time: 0ms
memory: 7908kb

input:

10 10
...***.*..
**...*.***
...***.*..
.**...*.*.
.*****..*.
..*.****.*
.**...****
..*..*.*.*
*.*.**....
....**...*

output:

1378

result:

ok 1 number(s): "1378"

Test #6:

score: -100
Wrong Answer
time: 290ms
memory: 219492kb

input:

3000 3000
.....................................................................................................................................................................................................................................................................................................

output:

17999998

result:

wrong answer 1st numbers differ - expected: '17999999', found: '17999998'