QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#408449#1950. SurveillanceohiostatescarletWA 1ms3844kbC++171.6kb2024-05-10 12:27:132024-05-10 12:27:13

Judging History

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

  • [2024-05-10 12:27:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3844kb
  • [2024-05-10 12:27:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define L long long
#define D double
#define P pair<D,D>

D integ(D x, D d) {
    return x*(1+1/(d-1)) - x * x * x / (3 * (d - 1));
}

D calcSol(D w, D h) {
    double res = -1;
    for (int i = 0; i < 2; i++) {
        double c = (1 + 1 / (h - 1) - w) * (h - 1);
        if (c >= 0) {
            c = sqrt(c);
            res += integ(1, h) - integ(c, h) + c * w;
        } else {
            res += integ(1, h);
        }
        swap(w, h);
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<P> nums(n);
    for (P&p:nums) cin >> p.first >> p.second;
    cout << setprecision(100);
    if (n == 4) {
        D res = 0;
        for (int i = 0; i < n; i++) {
            auto [x1, y1] = nums[i];
            auto [x2, y2] = nums[(i+1)%n];
            res += x1*y2-y1*x2;
        }
        cout << abs(res/2) << '\n';
    } else {
        for (int i = 0; i < n; i++) {
            auto [x1, y1] = nums[(i-1+n)%n];
            auto [x2, y2] = nums[i];
            auto [x3, y3] = nums[(i+1)%n];
            if ((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1) < 0) {
                auto [ox, oy] = nums[(i+3)%n];
                D sx = x2 - ox, sy = y2 - oy;
                D w = (nums[(i-1+n)%n].first - ox) / sx;
                D h = (nums[(i+1)%n].second - oy) / sy;
                // cout << ox << " " << oy << " " << sx << " " << sy << " " << w << " " << h << "\n";
                cout << abs(calcSol(w, h) * sx * sy) << '\n';
                return 0;
            }
        }
    }
    
}

詳細信息

Test #1:

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

input:

4
-5 6
-5 -2
10 -2
10 6

output:

120

result:

ok found '120.0000000', expected '120.0000000', error '0.0000000'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3804kb

input:

6
627 -788
444 -788
444 -986
-102 -986
-102 -993
627 -993

output:

nan

result:

wrong output format Expected double, but "nan" found