QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202868 | #2483. Roof Escape | whsyhyyh# | WA | 1ms | 6232kb | C++14 | 1.1kb | 2023-10-06 13:52:02 | 2023-10-06 13:52:03 |
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,&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;
}
Details
Tip: Click on the bar to expand more detailed information
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'