QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#356032#8236. Snake MoveUSTC_fish_touching_team#WA 140ms144984kbC++14956b2024-03-17 14:54:072024-03-17 14:54:08

Judging History

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

  • [2024-03-17 14:54:08]
  • 评测
  • 测评结果:WA
  • 用时:140ms
  • 内存:144984kb
  • [2024-03-17 14:54:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int n,m,k;
int a[N][N];
int x[N*N],y[N*N];
int f[N][N],lim[N][N];
int qx[N*N],qy[N*N],l,r;
char s[N]; 
void gx(int x,int y,int tx,int ty){
	if(tx>n||ty>m||tx<1||ty<1)return ;
	int w=lim[tx][ty];
	if(w<f[x][y]+1)w=f[x][y]+1;
	if(f[tx][ty]>w)f[tx][ty]=w,
	qx[++r]=tx,qy[r]=ty; 
}
int main(){
	cin>>n>>m>>k;
	memset(f,63,sizeof(f));
	for(int i=1;i<=k;i++){
		scanf("%d%d",&x[i],&y[i]);
		lim[x[i]][y[i]]=k-i+1;
	}
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=m;j++){
			if(s[j]=='#')lim[i][j]=1e9;
		}
	}
	qx[l=r=1]=x[1],qy[1]=y[1];
	f[x[1]][y[1]]=0;
	while(l<=r){
		int x=qx[l],y=qy[l];
		l++;
		gx(x,y,x+1,y);
		gx(x,y,x,y+1);
		gx(x,y,x-1,y);
		gx(x,y,x,y-1);
	}
	unsigned long long ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			
			if(f[i][j]>1e8)f[i][j]=0;
			ans=ans+f[i][j]*f[i][j];
		}
	}
	printf("%llu",ans);
} 

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 39160kb

input:

4 5 5
3 5
3 4
3 3
3 2
4 2
.....
.....
.....
.....

output:

293

result:

ok single line: '293'

Test #2:

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

input:

2 2 4
1 1
1 2
2 2
2 1
..
..

output:

14

result:

ok single line: '14'

Test #3:

score: 0
Accepted
time: 7ms
memory: 39196kb

input:

5 5 3
1 2
1 1
2 1
.....
.###.
.#.#.
.###.
.....

output:

407

result:

ok single line: '407'

Test #4:

score: -100
Wrong Answer
time: 140ms
memory: 144984kb

input:

3000 2900 1
1882 526
........................................................................................................#................................................................................................................................................................#................

output:

35144724941111

result:

wrong answer 1st lines differ - expected: '35141960580077', found: '35144724941111'