QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789292#115. Fences_8_8_#0 1ms3916kbC++231.5kb2024-11-27 19:47:252024-11-27 19:47:25

Judging History

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

  • [2024-11-27 19:47:25]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3916kb
  • [2024-11-27 19:47:25]
  • 提交

answer

#include <bits/stdc++.h> 

using namespace std;

typedef long long ll;
typedef long double ld;


const int N = (int)3e3 + 12, MOD = (int)1e9 + 7;


int n, s;

struct pt{
    int x, y;
};
void in(pt &a) {
    cin >> a.x >> a.y;
}
vector<array<pt, 2>> a;

ld dist(pt a, pt b) {
    ld x = (a.x - b.x) ,y = (b.y - a.y);
    return sqrtl(x * x + y * y);
}
bool check(pt x, pt y) {
    if(x.x == s) {
        if(y.x >= x.x) return 1;
    } else {
        if(y.x <= x.x) return 1;
    }
    if(x.y == s) {
        if(y.y >= x.y) return 1;
    } else {
        if(y.y <= x.y) return 1;
    }
    return 0;
}
ld get(pt x, pt y) {
    ld ret = (1e18);
    if(check(a[0][0], x) && check(a[0][1], y)) {
        ret = min(ret, dist(a[0][0], x) + dist(a[0][1], y) + s * 4);
        // cout << a[0][0].x << ' ' << a[0][0].y << ' ' << x.x << ' ' << x.y << '\n';
    }
    if(check(a[0][1], x) && check(a[0][0], y)) {
        ret = min(ret, dist(a[0][1], x) + dist(a[0][0], y) + s * 4);
    }
    return ret;
}
void test() {
    cin >> n >> s;
    a.resize(n);
    for(int i = 0; i < n; i++) {
        in(a[i][0]);in(a[i][1]);
    }
    ld res = s * 8;
    res = min({res, get({-s, -s}, {s, s}), get({-s, s}, {s, -s})});
    // cout << get({-s, s}, {s, -s}) << '\n';
    cout << fixed << setprecision(7) << res << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    // cin >> t;

    while(t--) 
        test();

    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 18
Accepted
time: 1ms
memory: 3868kb

input:

1 20
-132 -148 7 -48

output:

160.0000000

result:

ok found '160.00000', expected '160.00000', error '0.00000'

Test #2:

score: 18
Accepted
time: 1ms
memory: 3916kb

input:

1 40
40 81 118 181

output:

320.0000000

result:

ok found '320.00000', expected '320.00000', error '0.00000'

Test #3:

score: 18
Accepted
time: 1ms
memory: 3824kb

input:

1 60
-189 -95 -114 -101

output:

480.0000000

result:

ok found '480.00000', expected '480.00000', error '0.00000'

Test #4:

score: 0
Wrong Answer
time: 1ms
memory: 3900kb

input:

1 80
-17 134 -3 128

output:

626.9245549

result:

wrong answer 1st numbers differ - expected: '640.00000', found: '626.92455', error = '0.02043'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%