QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203419 | #2483. Roof Escape | Delay_for_five_minutes# | WA | 0ms | 3876kb | C++20 | 1.2kb | 2023-10-06 17:18:26 | 2023-10-06 17:18:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+3;
int n,m,sx,sy,tx,ty;
vector<vector<int>> a;
int sgn(int x){
if(!x)return 0;
return x>0?1:-1;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
cin>>n>>m>>sx>>sy>>tx>>ty;
a.resize(m/2+1);
for(int i=1;i<=m/2;++i){
a[i].resize(n/2+1);
for(int j=1;j<=n/2;++j)cin>>a[i][j];
}
int dx=abs(tx-sx),dy=abs(ty-sy);
int nx=sgn(tx-sx),ny=sgn(ty-sy);
int T=dx*dy;
int ans=0;
int x=sx/2+1,y=sy/2+1;
if(nx&&ny){
for(int t=0;t<=T;++t){
int totx=dy+t,toty=dx+t;
if(!(totx%(2*dy))&&!(toty%(2*dx))){
int maxh=max(max(a[x][y],a[x+nx][y+ny]),max(a[x+nx][y],a[x][y+ny]));
ans+=2*maxh-a[x][y]-a[x+nx][y+ny];
x+=nx,y+=ny;
}
else if(!(totx%(2*dy))){
ans+=abs(a[x+nx][y]-a[x][y]);
x+=nx;
}
else if(!(toty%(2*dx))){
ans+=abs(a[x][y+ny]-a[x][y]);
y+=ny;
}
}
}
else if(nx){
for(int t=1;t<=dx;t+=2){
ans+=abs(a[x+nx][y]-a[x][y]);
x+=nx;
}
}
else if(ny){
for(int t=1;t<=dy;t+=2){
ans+=abs(a[x][y+ny]-a[x][y]);
y+=ny;
}
}
cout<<fixed<<setprecision(12)<<ans+sqrt(1ll*dx*dx+1ll*dy*dy)<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3876kb
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:
102.083189157585
result:
wrong answer 1st numbers differ - expected: '53.08319', found: '102.08319', error = '0.92308'