QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203051#2483. Roof EscapeSolitaryDream#WA 1ms6316kbC++171.9kb2023-10-06 15:03:252023-10-06 15:03:25

Judging History

你现在查看的是最新测评结果

  • [2023-10-06 15:03:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6316kb
  • [2023-10-06 15:03:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int n, m, sx, sy, ex, ey;
vector<int> mp[N];
inline double Sqr(double x) {
    return x * x;
}
inline int Det(int a, int b, int u, int v, int x, int y) {
    u -= a; v -= b;
    x -= a; y -= b;
    return u * y - x * v;
}
signed main() {
    scanf("%lld%lld%lld%lld%lld%lld", &n, &m, &sx, &sy, &ex, &ey);
    n /= 2; m /= 2;
    for (int i = 0; i <= n + 1; ++i) mp[i].resize(m + 2);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            scanf("%lld", &mp[i][j]);
    if (sx > ex) {
        sx = 2 * n - sx; ex = 2 * n - ex;
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j) 
                if (i < n - i + 1) swap(mp[i][j], mp[n - i + 1][j]);
    }
    if (sy > ey) {
        sy = 2 * m - sy; ey = 2 * m - ey;
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j) 
                if (j < m - j + 1) swap(mp[i][j], mp[i][m - j + 1]);
    }
    double ans1 = sqrt(Sqr(sx - ex) + Sqr(sy - ey));
    int ans2 = 0;
    for (int i = (sx + 1) / 2, j = (sy + 1) / 2; ; ) {
        if (i == (ex + 1) / 2 && j == (ey + 1) / 2) break; 
        // printf("%lld %lld\n", i, j);
        int d = Det(sx, sy, 2 * i, 2 * j, ex, ey);
        // printf("%lld\n", d);
        if (d > 0) {
            ans2 += abs(mp[i][j] - mp[i][j + 1]);
            ++j;
        } else if (d == 0) {
            vector<int> a({mp[i][j], mp[i + 1][j], mp[i][j + 1], mp[i + 1][j + 1]});
            sort(a.begin(), a.end());
            int h = a[2];
            ans2 += abs(mp[i][j] - h) + abs(mp[i + 1][j + 1] - h);
            ++i; ++j;
        } else {
            ans2 += abs(mp[i][j] - mp[i + 1][j]);
            ++i;
        }
    }    
    printf("%.10lf\n", ans1 + ans2);
    return 0;
}
/*
4 8 1 1 3 7
1 2 5 1
1 5 2 1
*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 6220kb

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: 1ms
memory: 6252kb

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: 6200kb

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: 6256kb

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: 1ms
memory: 6272kb

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: 1ms
memory: 6272kb

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: 1ms
memory: 6272kb

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: 1ms
memory: 6212kb

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: 1ms
memory: 6312kb

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: 1ms
memory: 6252kb

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: 1ms
memory: 6156kb

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: 1ms
memory: 6264kb

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: -100
Wrong Answer
time: 1ms
memory: 6316kb

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.0000000000

result:

wrong answer 1st numbers differ - expected: '30.00000', found: '36.00000', error = '0.20000'