QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203410 | #2483. Roof Escape | Delay_for_five_minutes# | WA | 1ms | 3980kb | C++20 | 1.2kb | 2023-10-06 17:15:35 | 2023-10-06 17:15:35 |
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(n/2+1);
for(int i=1;i<=n/2;++i){
a[i].resize(m/2+1);
for(int j=1;j<=m/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;
ll 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: 100
Accepted
time: 0ms
memory: 3920kb
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: 0ms
memory: 3876kb
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: 3888kb
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: 3932kb
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: 3868kb
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: 3736kb
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: 0
Accepted
time: 0ms
memory: 3828kb
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:
10.000000000000
result:
ok found '10.00000', expected '10.00000', error '0.00000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
2 28 1 9 1 23 2 1 1 3 2 1 2 0 3 1 1 1 1 3
output:
23.000000000000
result:
ok found '23.00000', expected '23.00000', error '0.00000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
2 18 1 11 1 13 1 0 2 0 4 0 2 2 4
output:
4.000000000000
result:
ok found '4.00000', expected '4.00000', error '0.00000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
2 400 1 133 1 399 3 6 2 3 0 2 0 3 6 1 6 3 1 5 3 1 6 3 0 2 4 3 3 2 3 0 6 4 2 5 0 3 1 1 3 0 1 3 0 3 5 2 1 2 4 5 0 2 1 0 4 7 3 1 6 4 3 5 2 0 0 3 2 0 2 7 1 0 2 1 2 0 3 0 3 0 6 2 0 4 2 0 3 3 5 0 3 6 3 0 3 2 1 5 1 1 2 6 1 2 1 0 1 2 1 3 2 4 0 5 1 4 2 2 4 4 3 2 1 5 2 3 1 0 0 2 7 5 0 0 2 1 1 0 4 4 2 0 1 4 5 ...
output:
560.000000000000
result:
ok found '560.00000', expected '560.00000', error '0.00000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
2 200 1 117 1 97 1 7 2 2 0 4 3 0 0 0 0 5 4 0 4 4 7 0 2 7 3 5 0 1 2 4 2 0 0 0 3 3 1 3 2 2 2 0 3 3 3 0 0 3 1 3 4 2 1 6 0 1 0 2 1 3 5 2 5 2 0 1 0 1 0 1 1 3 3 3 1 5 1 1 7 0 2 2 2 7 2 1 4 3 1 1 0 0 1 2 1 0 6 2 2 2 1 1 1 0
output:
46.000000000000
result:
ok found '46.00000', expected '46.00000', error '0.00000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
2 132 1 41 1 65 3 0 3 3 2 2 5 2 0 2 3 3 2 1 2 4 0 4 5 1 2 1 0 2 2 1 0 6 1 1 5 2 1 0 2 4 2 5 1 6 0 3 1 1 5 1 2 7 2 2 2 1 5 6 0 5 4 0 5 2 1 1 1 4 0 0
output:
49.000000000000
result:
ok found '49.00000', expected '49.00000', error '0.00000'
Test #13:
score: -100
Wrong Answer
time: 0ms
memory: 3924kb
input:
4 100 3 37 3 53 2 0 1 3 0 4 2 0 0 2 0 1 0 4 4 0 5 5 3 6 1 4 1 1 6 0 1 3 3 5 5 4 3 0 2 0 2 3 0 1 0 3 4 4 5 3 3 0 0 2 4 1 0 3 0 5 1 2 1 4 1 0 2 0 2 0 0 0 0 2 4 1 4 0 1 5 4 0 0 2 1 7 6 2 1 4 0 0 0 6 5 5 2 0 0 3 3 1 2 4
output:
36.000000000000
result:
wrong answer 1st numbers differ - expected: '30.00000', found: '36.00000', error = '0.20000'