QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202868#2483. Roof Escapewhsyhyyh#WA 1ms6232kbC++141.1kb2023-10-06 13:52:022023-10-06 13:52:03

Judging History

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

  • [2023-10-06 13:52:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6232kb
  • [2023-10-06 13:52:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define db double
const int N = 1e5+9;
const db eps = 1e-6;
int w,h,sx,sy,ex,ey;
vector<int >v[N];
int hei(db x,db y){
	int a=(int)(x-eps)/2+1;
	int b=(int)(y-eps)/2+1;
	return v[a][b];
}
int main(){
	scanf("%d%d%d%d%d%d",&w,&h,&sx,&sy,&ex,&ey);
	db ans=sqrt((ex-sx)*(ex-sx)+(ey-sy)*(ey-sy));
	for(int i=1;i<=w/2;i++){
		v[i].push_back(0);
		for(int j=1;j<=h/2;j++){
			int x;scanf("%d",&x);v[i].push_back(x);
		}
	}
	for(int i=sx+1;i<=ex-1;i+=2){
		db x=i,y=sy+(db)(i-sx)*(db)(ey-sy)/(db)(ex-sx);
		ans+=abs(hei(x,y)-hei(x+1,y))*2;	
	}
	for(int i=sx-1;i>=ex+1;i-=2){
		db x=i,y=sy+(db)(i-sx)*(db)(ey-sy)/(db)(ex-sx);
		ans+=abs(hei(x,y)-hei(x-1,y))*2;
	}
	
	for(int i=sy+1;i<=ey-1;i+=2){
		db x=sx+(db)(i-sy)*(db)(ex-sx)/(db)(ey-sy),y=i;
		if(abs((int)(x+0.5)-x)<eps) continue;		
		ans+=abs(hei(x,y)-hei(x,y+1))*2;	
	}
	for(int i=sy-1;i>=ey+1;i-=2){
		db x=sx+(db)(i-sy)*(db)(ex-sx)/(db)(ey-sy),y=i;	
		if(abs((int)(x+0.5)-x)<eps) continue;		
		ans+=abs(hei(x,y)-hei(x,y-1))*2;	
	}
	printf("%.12lf\n",ans);
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6232kb

input:

4 26 1 1 3 25
0 1
0 5
5 5
0 1
2 1
4 1
5 0
0 0
1 0
6 4
3 2
5 4
1 5

output:

82.083189157585

result:

wrong answer 1st numbers differ - expected: '53.08319', found: '82.08319', error = '0.54631'