QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203525#2483. Roof EscapeBoulevardDust#WA 2ms8428kbC++201.5kb2023-10-06 17:57:272023-10-06 17:57:28

Judging History

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

  • [2023-10-06 17:57:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8428kb
  • [2023-10-06 17:57:27]
  • 提交

answer

#include<bits/stdc++.h>
#define N 200005
#define re 
#define ll long long
#define P 167772161
using namespace std;
int n,m,K,q,T;
inline void Rd(int &res){
	re char c;res=0;
	while(c=getchar(),c<48);
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>47);
}
vector<int>a[N];
const double eps=1e-8;
int la=-1;
double ans;
void Add(int v){
//	printf("Add:%d\n",v);
	if(la>=0)ans+=abs(v-la);
	la=v;
}
int main(){
	int Sx,Sy,Ex,Ey;
	Rd(m),Rd(n),Rd(Sx),Rd(Sy),Rd(Ex),Rd(Ey);
	n/=2,m/=2;
	for(re int i=0;i<=n;i++)a[i].resize(m+1);
	for(re int i=1;i<=n;i++)
		for(re int j=1;j<=m;j++)Rd(a[i][j]);
	
	
	ans=sqrt(1.0*(Sx-Ex)*(Sx-Ex)+1.0*(Sy-Ey)*(Sy-Ey));
	if(Sx>Ex)swap(Sx,Ex),swap(Sy,Ey);
	
	if(Sx==Ex){
		for(re int i=min(Sy,Ey)+1;i<=max(Sy,Ey)+1;i+=2){
			Add(a[(Sx+1)/2][i/2]);
		}
		printf("%.10lf\n",ans);
		return 0;
	}
//	printf("%d %d\n",a[2][4],a[1][3]);
	double k=1.0*(Ey-Sy)/(Ex-Sx);
	for(re int x=Sx+1;x<=Ex-1;x+=2){
		double y=k*(x-Sx)+Sy;
		int ty=(int)(y+eps);
		
		if(fabs(y-ty)<eps&&ty%2==0){
			if(Sy<Ey){
				Add(a[ty/2][x/2]);
				if(a[ty/2][x/2]<max(a[ty/2][x/2+1],a[ty/2+1][x/2]))Add(max(a[ty/2][x/2+1],a[ty/2+1][x/2]));
				Add(a[ty/2+1][x/2+1]);
			}
			else{
				Add(a[ty/2+1][x/2]);
				if(a[ty/2+1][x/2]<max(a[ty/2+1][x/2+1],a[ty/2][x/2]))Add(max(a[ty/2+1][x/2+1],a[ty/2][x/2]));
				Add(a[ty/2][x/2+1]);
			}
		}
		else{
			Add(a[(int)(y/2+1)][x/2]);
			Add(a[(int)(y/2+1)][x/2+1]);
		}
	}
	printf("%.10lf\n",ans);
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 8428kb

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:

29.0831891576

result:

wrong answer 1st numbers differ - expected: '53.08319', found: '29.08319', error = '0.45212'