QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203549 | #2483. Roof Escape | BoulevardDust# | WA | 0ms | 8544kb | C++20 | 1.4kb | 2023-10-06 18:01:56 | 2023-10-06 18:01:57 |
Judging History
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+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+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: 0ms
memory: 8544kb
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'