QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202998 | #2483. Roof Escape | whsyhyyh# | WA | 0ms | 6024kb | C++14 | 2.0kb | 2023-10-06 14:31:52 | 2023-10-06 14:31:52 |
Judging History
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,&sy,&sx,&ey,&ex);
db ans=sqrt((ex-sx)*(ex-sx)+(ey-sy)*(ey-sy));
for(int i=1;i<=h/2;i++){
v[i].push_back(0);
for(int j=1;j<=w/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);
if(abs((int)(y+0.5)-y)<eps) continue;
ans+=abs(hei(x-1,y)-hei(x+1,y));
}
for(int i=sx-1;i>=ex+1;i-=2){
db x=i,y=sy+(db)(i-sx)*(db)(ey-sy)/(db)(ex-sx);
if(abs((int)(y+0.5)-y)<eps) continue;
ans+=abs(hei(x+1,y)-hei(x-1,y));
}
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-1)-hei(x,y+1));
}
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+1)-hei(x,y-1));
}
for(int i=sx+1;i<=ex-1;i+=2){
db x=i,y=sy+(db)(i-sx)*(db)(ey-sy)/(db)(ex-sx);
if(abs((int)(y+0.5)-y)<eps){
int d;
if(ey>sy) d=1;
else if(ey==sy) d=0;
else d=-1;
int t=min(hei(x+1,y-d),hei(x-1,y+d));
if(t>hei(x-1,y-d)) ans+=abs(t-hei(x-1,y-d))+abs(t-hei(x+1,y+d));
else ans+=abs(hei(x-1,y-d)-hei(x+1,y+d));
}
}
for(int i=sx-1;i>=ex+1;i-=2){
db x=i,y=sy+(db)(i-sx)*(db)(ey-sy)/(db)(ex-sx);
if(abs((int)(y+0.5)-y)<eps){
int d;
if(ey>sy) d=1;
else if(ey==sy) d=0;
else d=-1;
int t=min(hei(x-1,y-d),hei(x+1,y+d));
if(t>hei(x+1,y-d)) ans+=abs(hei(x+1,y-d)-t)+abs(t-hei(x-1,y+d));
else ans+=abs(hei(x+1,y-d)-hei(x-1,y+d));
}
}
printf("%.12lf\n",ans);
return 0;
}
/*
8 8 7 7 1 1
2 3 2 0
2 1 1 2
1 2 0 0
0 0 0 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6024kb
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:
48.083189157585
result:
wrong answer 1st numbers differ - expected: '53.08319', found: '48.08319', error = '0.09419'