QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203290 | #2483. Roof Escape | PhantomThreshold# | WA | 1ms | 3796kb | C++20 | 2.3kb | 2023-10-06 16:37:03 | 2023-10-06 16:37:04 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int maxn = 105000<<2;
int n,m,N;
int sx,sy,tx,ty;
vector< vector<int> >h;
int sqr(int x){ return x*x; }
double ans;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>m>>n>>sy>>sx>>ty>>tx;
ans= sqrt( sqr(sx-tx)+sqr(sy-ty) );
for(int i=1;i<=n/2;i++)
{
vector<int>_;
for(int j=1;j<=m/2;j++)
{
int hi; cin>>hi;
_.push_back(hi);
_.push_back(hi);
}
h.push_back(_);
h.push_back(_);
}
if(sx>tx)
{
for(int i=0;i<n;i++) if(i<n-i-1)
{
swap(h[i],h[n-i-1]);
}
swap(sx,tx);
}
int dx=tx-sx, dy=ty-sy;
{
int d= __gcd(abs(dx),abs(dy));
dx/=d, dy/=d;
}
if(sx==tx)
{
if(sy<ty)
{
for(int j=sy;j<ty;j++) ans+=abs(h[sx][j]-h[sx][j+1]);
}
else
{
for(int j=sy;j>ty;j--) ans+=abs(h[sx][j]-h[sx][j-1]);
}
}
else
{
for(int i=sx+1,j=sy;i<=tx;i++)
{
double d, u;
if(sy<ty)
{
d= (double)sy+(i-1-sx)*dy/dx;
u= (double)sy+(i-sx)*dy/dx;
while( (j+1)<=u )
{
if(j+1==u && (i-sx)*dy%dx==0)
{
if( min(h[i-1][j+1],h[i][j]) > max(h[i-1][j],h[i][j+1]) )
{
int temp= min(h[i-1][j+1],h[i][j]);
ans+= abs( temp-h[i-1][j] ) + abs( temp-h[i][j+1] );
j++;
}
else
{
ans+= abs(h[i-1][j]-h[i][j+1]);
j++;
}
}
else
{
ans+= abs(h[i-1][j]-h[i-1][j+1]);
j++;
}
}
if( (i-sx)*abs(dy)%dx!=0 )
{
ans+= abs( h[i-1][j]-h[i][j] );
}
}
else
{
u= (double)sy+(i-1-sx)*dy/dx;
d= (double)sy+(i-sx)*dy/dx;
while( (j-1)>=d )
{
if(j-1==d && (i-sx)*abs(dy)%dx==0)
{
if( min(h[i-1][j-1],h[i][j]) > max(h[i-1][j],h[i][j-1]) )
{
int temp= min(h[i-1][j-1],h[i][j]);
ans+= abs( temp-h[i-1][j] ) + abs( temp-h[i][j-1] );
j--;
}
else
{
ans+= abs(h[i-1][j]-h[i][j-1]);
}
}
else
{
ans+= abs(h[i-1][j]-h[i-1][j-1]);
j--;
}
}
if( (i-sx)*abs(dy)%dx!=0 )
{
ans+= abs( h[i-1][j]-h[i][j] );
}
}
}
}
cout<<fixed<<setprecision(12)<<ans<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3672kb
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:
53.083189157585
result:
ok found '53.08319', expected '53.08319', error '0.00000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
8 8 1 7 7 1 2 3 2 0 2 1 1 2 1 2 0 0 0 0 0 1
output:
14.485281374239
result:
ok found '14.48528', expected '14.48528', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 2 1 1 1 1 100
output:
0.000000000000
result:
ok found '0.00000', expected '0.00000', error '-0.00000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
4 4 1 1 3 3 100 1 1 100
output:
2.828427124746
result:
ok found '2.82843', expected '2.82843', error '0.00000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3796kb
input:
4 4 1 1 3 3 1 100 100 1
output:
200.828427124746
result:
ok found '200.82843', expected '200.82843', error '0.00000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
4 4 1 3 3 1 1 100 100 1
output:
2.828427124746
result:
ok found '2.82843', expected '2.82843', error '0.00000'
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3684kb
input:
2 56 1 23 1 17 1 0 1 0 1 0 0 4 1 3 1 1 3 0 3 1 1 0 0 2 0 2 1 0 1 0 0 0
output:
6.000000000000
result:
wrong answer 1st numbers differ - expected: '10.00000', found: '6.00000', error = '0.40000'