QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#373557#3663. The Biggest TriangleMogaWA 1ms3832kbC++141.8kb2024-04-01 20:15:302024-04-01 20:15:31

Judging History

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

  • [2024-04-01 20:15:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3832kb
  • [2024-04-01 20:15:30]
  • 提交

answer

#include<bits/stdc++.h>
#define MOGA ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef long double ld;
using namespace std;
int n, t = 1, k, mask;
struct point {
    ld a, b;
};
vector<point>v;
point equ(double x, double y, double a, double b) {
    point cur;
    if (x == a) {
        cur.a = 1e9;
        cur.b = x;
    }
    else {
        cur.a =(y - b) / (x - a);
        cur.b = y - cur.a * x;
    }
    return cur;
}
point inter(point a, point b) {
    if (a.a == b.a)
    {
        a.a = -1e9;
        return a;
    }
    point x;
    x.a = (a.b - b.b) / (b.a - a.a);
    x.b = (x.a * a.a) + a.b;
    return x;
}
double area(point a, point b, point c) {
    return sqrtl((a.a - b.a) * (a.a - b.a) + (-b.b + a.b) * (-b.b + a.b)) +
        sqrtl((a.a - c.a) * (a.a - c.a) + (-c.b + a.b) * (-c.b + a.b)) +
        sqrtl((c.a - b.a) * (c.a - b.a) + (-b.b + c.b) * (-b.b + c.b));
}
void go() {
    cin >> n;
    for (int i = 0;i < n;i++) {
        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        v.push_back(equ(x1, y1, x2, y2));
    }
    double ans = 0;
    for (auto i : v) {
        for (auto j : v) {
            for (auto k : v) {
                point f1 = inter(i, j), f2 = inter(k, j), f3 = inter(i, k);
                if (f1.a == LDBL_MAX || f2.a == LDBL_MAX || f3.a == LDBL_MAX)continue;
                double b = area(f1, f2, f3);
                ans = max(ans, b);
            }
        }
    }
    if (ans != 0)
        cout << fixed << setprecision(8) << ans;
    else
        cout << "no triangle";
}
int main()
{
    MOGA
        //  cin >> t;
        for (int i = 1;i <= t;i++)
        {
            go();
            cout << '\n';
        }
    return 0;
}

详细

Test #1:

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

input:

3
0 0 0 1
0 0 1 0
0 1 1 0

output:

2000000002.00000000

result:

wrong answer