QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168252 | #2483. Roof Escape | LaStataleBlue# | WA | 1ms | 3796kb | C++23 | 2.7kb | 2023-09-08 01:40:33 | 2023-09-08 01:40:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using T = long long; //o double o long double
typedef complex<T> pt;
const T EPS = 1e-10; //per i double o long double
#define X real()
#define Y imag()
#define M_PI acos(-1)
// *** Punti ***
T dot(pt v, pt w) { return (conj(v) * w).X; }
T cross(pt v, pt w) { return (conj(v) * w).Y; }
T orient(pt a, pt b, pt c) { return cross(b-a, c-a); }
pt translate(pt v, pt p) { return p+v; }
pt perp(pt p) { return {-p.Y, p.X}; }
bool isPerp(pt v, pt w) { return dot(v,w) == 0; }
pt scale(pt c, T factor, pt p) { return c+(p-c)*factor; }
struct line {
pt v; T c;
// From direction vector v and offset c
line(pt v, T c) : v(v), c(c) {}
// From equation ax+by=c
line(T a, T b, T c) : v({b,-a}), c(c) {}
// From points P and Q
line(pt p, pt q) : v(q-p), c(cross(v,p)) {}
T side(pt p) { return cross(v,p)-c; }
T dist(pt p) {return abs(side(p)) / abs(v);}
};
void solve(int t){
long long h,w,sx,sy,ex,ey;
cin>>h>>w>>sx>>sy>>ex>>ey;
line l({sx,sy},{ex,ey});
vector mat(h,vector(w,0ll));
for(int i=0;i<h/2;i++){
for(int j=0;j<w/2;j++){
cin>>mat[i][j];
}
}
long double ans=0;
for(int i=2;i<w;i+=2){
for(int j=0;j<h;j+=2){
pt p1(j,i),p2(j+2,i);
if(l.side(p1)*l.side(p2)<0){
ans+=abs(mat[j/2][i/2-1]-mat[j/2][i/2]);
}
}
}
for(int i=2;i<h;i+=2){
for(int j=0;j<w;j+=2){
pt p1(i,j),p2(i,j+2);
if(l.side(p1)*l.side(p2)<0){
ans+=abs(mat[i/2-1][j/2]-mat[i/2][j/2]);
}
}
}
for(int i=2;i<h;i+=2){
for(int j=2;j<w;j+=2){
pt p(i,j);
if(l.side(p)==0){
long long maxi = max({mat[i/2][j/2],mat[i/2-1][j/2],mat[i/2][j/2-1],mat[i/2-1][j/2-1]});
long long part,dest;
if((sx<i && sy<j) || (ex<i && ey<j)){
part = mat[i/2][j/2];
dest = mat[i/2-1][j/2-1];
}else{
part = mat[i/2-1][j/2];
dest = mat[i/2][j/2-1];
}
ans+=abs(maxi-part)+abs(maxi-dest);
}
}
}
ans+=sqrtl((sx-ex)*(sx-ex)+(sy-ey)*(sy-ey));
cout<<setprecision(20)<<ans<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)solve(i);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3780kb
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.083189157584590959
result:
ok found '53.08319', expected '53.08319', error '0.00000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3608kb
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.485281374238570293
result:
ok found '14.48528', expected '14.48528', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
2 2 1 1 1 1 100
output:
0
result:
ok found '0.00000', expected '0.00000', error '-0.00000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
4 4 1 1 3 3 100 1 1 100
output:
2.8284271247461900975
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.8284271247461901
result:
ok found '200.82843', expected '200.82843', error '0.00000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
4 4 1 3 3 1 1 100 100 1
output:
2.8284271247461900975
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:
43
result:
wrong answer 1st numbers differ - expected: '10.00000', found: '43.00000', error = '3.30000'