QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203613 | #2483. Roof Escape | Vengeful_Spirit | WA | 1ms | 4220kb | C++14 | 1.7kb | 2023-10-06 18:41:45 | 2023-10-06 18:41:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int W, H;
int a[100006];
int ID(int i, int j) {
return (j-1)*H/2+i;
}
bool chk(int x, int y, int xi, int yi, int xj, int yj) {
long long v1 = 1ll*x*yi-1ll*y*xi;
long long v2 = 1ll*x*yj-1ll*y*xj;
return (v1>0&&v2<0)||(v1<0&&v2>0);
}
bool check(int x, int y, int xx, int yy, int u, int v, int uu, int vv) {
return chk(xx-x, yy-y, u-x, v-y, uu-x, vv-y) && chk(uu-u, vv-v, x-u, y-v, xx-u, yy-v);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> W >> H;
int sx, sy, ex, ey;
cin >> sx >> sy >> ex >> ey;
double ans = sqrt(1ll*(sx-ex)*(sx-ex)+1ll*(sy-ey)*(sy-ey));
vector<pair<int,pair<int,int>>> s;
for(int i = 1; i <= H/2; ++i) {
for(int j = 1; j <= W/2; ++j) {
cin >> a[ID(j, i)];
if(check(sx, sy, ex, ey, 2*j-2, 2*i-2, 2*j, 2*i)
|| check(sx, sy, ex, ey, 2*j, 2*i-2, 2*j-2, 2*i)
|| (j == (sx+1)/2 && i == (sy+1)/2)
|| (j == (ex+1)/2 && i == (ey+1)/2)) {
s.push_back({abs(j*2-1-sx)+abs(i*2-1-sy), {j, i}});
}
}
}
sort(s.begin(), s.end());
for(int i = 0; i < s.size()-1; ++i) {
auto [w, o] = s[i]; auto [x, y] = o;
// cerr << x << " " << y << "\n";
auto [ww, oo] = s[i+1]; auto [xx, yy] = oo;
if(x==xx||y==yy) ans += abs(a[ID(xx, yy)]-a[ID(x, y)]);
else {
int h1 = a[ID(xx, yy)], h2 = a[ID(x, y)];
int h3 = min(a[ID(x, yy)], a[ID(xx, y)]);
if(h3 > h1 && h3 > h2) ans += abs(h3-h2)+abs(h3-h1);
else ans += abs(h2-h1);
}
}
cout << fixed << setprecision(10) << ans;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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.0831891576
result:
ok found '53.08319', expected '53.08319', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3972kb
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.4852813742
result:
ok found '14.48528', expected '14.48528', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
2 2 1 1 1 1 100
output:
0.0000000000
result:
ok found '0.00000', expected '0.00000', error '-0.00000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
4 4 1 1 3 3 100 1 1 100
output:
2.8284271247
result:
ok found '2.82843', expected '2.82843', error '0.00000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
4 4 1 1 3 3 1 100 100 1
output:
200.8284271247
result:
ok found '200.82843', expected '200.82843', error '0.00000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
4 4 1 3 3 1 1 100 100 1
output:
2.8284271247
result:
ok found '2.82843', expected '2.82843', error '0.00000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3792kb
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.0000000000
result:
ok found '10.00000', expected '10.00000', error '0.00000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
2 28 1 9 1 23 2 1 1 3 2 1 2 0 3 1 1 1 1 3
output:
23.0000000000
result:
ok found '23.00000', expected '23.00000', error '0.00000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 4072kb
input:
2 18 1 11 1 13 1 0 2 0 4 0 2 2 4
output:
4.0000000000
result:
ok found '4.00000', expected '4.00000', error '0.00000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 4004kb
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.0000000000
result:
ok found '560.00000', expected '560.00000', error '0.00000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3932kb
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.0000000000
result:
ok found '46.00000', expected '46.00000', error '0.00000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3792kb
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.0000000000
result:
ok found '49.00000', expected '49.00000', error '0.00000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3884kb
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:
30.0000000000
result:
ok found '30.00000', expected '30.00000', error '0.00000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
4 80 1 67 3 57 1 4 0 5 1 3 1 6 0 0 5 0 0 1 1 0 0 6 3 0 4 0 1 0 1 2 1 2 0 0 6 2 2 2 1 3 0 3 3 2 2 2 0 3 1 2 0 2 0 0 6 6 1 4 1 4 0 4 1 7 1 3 6 1 3 3 5 5 1 1 4 3 1 4 3 5 5 1 2 1
output:
25.1980390272
result:
ok found '25.19804', expected '25.19804', error '0.00000'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
6 66 1 59 1 51 2 1 1 5 2 6 2 3 2 0 2 6 2 3 2 0 4 2 4 1 5 2 0 6 4 2 2 0 0 1 1 2 0 3 4 2 0 2 1 1 1 2 4 0 3 0 1 0 2 6 5 1 0 5 0 2 1 1 3 3 2 5 3 3 1 4 1 7 1 3 2 5 2 0 5 3 4 5 4 3 0 5 2 4 0 6 3 2 4 4 1 2 0 0 6 0 4 4 3
output:
17.0000000000
result:
ok found '17.00000', expected '17.00000', error '0.00000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
6 56 1 19 5 19 1 5 5 1 1 4 4 2 4 0 0 2 0 1 4 4 2 3 3 1 5 4 4 2 4 4 3 3 0 2 0 1 1 7 2 5 0 3 1 4 1 2 6 0 5 3 1 2 0 6 3 5 2 1 1 2 4 0 1 0 0 0 3 5 1 2 5 2 0 4 5 1 6 5 2 3 2 4 5 6 4 5 7 0
output:
9.0000000000
result:
ok found '9.00000', expected '9.00000', error '0.00000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
8 50 1 31 3 7 4 3 3 1 1 3 0 1 6 0 1 4 0 0 1 5 1 3 0 3 0 4 0 0 3 3 3 5 2 3 2 1 0 5 1 4 1 5 3 7 1 2 4 3 6 0 3 1 2 5 6 0 4 5 4 2 2 1 1 7 6 2 4 3 2 3 3 0 0 0 2 3 2 0 4 1 0 1 3 3 2 0 2 5 2 6 1 0 3 1 2 1 5 2 4 1 0 2 4 2
output:
52.0831891576
result:
ok found '52.08319', expected '52.08319', error '0.00000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
8 44 3 13 7 17 1 4 1 5 2 1 0 4 1 0 5 2 0 0 4 0 1 0 4 2 5 2 2 0 0 1 1 1 1 0 2 4 1 0 3 3 4 0 1 0 0 2 2 4 4 1 1 0 4 7 2 2 4 4 4 5 0 2 0 2 4 2 6 2 4 1 3 0 4 6 2 4 7 3 2 0 6 4 1 0 1 2 5 1 2 2 3 0
output:
7.6568542495
result:
ok found '7.65685', expected '7.65685', error '0.00000'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
100 100 21 15 63 83 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
79.9249648108
result:
ok found '79.92496', expected '79.92496', error '0.00000'
Test #20:
score: 0
Accepted
time: 1ms
memory: 4156kb
input:
300 300 199 221 255 3 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 ...
output:
271.0777643394
result:
ok found '271.07776', expected '271.07776', error '0.00000'
Test #21:
score: 0
Accepted
time: 1ms
memory: 4088kb
input:
20 500 5 53 1 359 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
306.0261426741
result:
ok found '306.02614', expected '306.02614', error '0.00000'
Test #22:
score: 0
Accepted
time: 1ms
memory: 4220kb
input:
20 500 19 427 1 31 0 0 0 0 0 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0...
output:
485.4088798198
result:
ok found '485.40888', expected '485.40888', error '0.00000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 4008kb
input:
500 20 367 15 323 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
44.7213595500
result:
ok found '44.72136', expected '44.72136', error '0.00000'
Test #24:
score: -100
Wrong Answer
time: 0ms
memory: 3976kb
input:
500 20 153 13 153 5 1 0 1 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 ...
output:
10.0000000000
result:
wrong answer 1st numbers differ - expected: '11.00000', found: '10.00000', error = '0.09091'