QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#373556 | #3663. The Biggest Triangle | Moga | WA | 0ms | 3872kb | C++14 | 2.2kb | 2024-04-01 20:14:45 | 2024-04-01 20:14:46 |
Judging History
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 if (y == b) {
cur.a = 1e8;
cur.b = y;
}
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;
}
if (a.a == 1e9)
{
swap(a.b, a.a);
a.b = (b.a * a.a) + b.b;
return a;
}
if (b.a == 1e9)
{
swap(b.b, b.a);
b.b = (b.a * a.a) + a.b;
return b;
}
if (a.a == 1e8)
{
a.a = (a.b - b.b) / b.a;
return a;
}
if (b.a == 1e8)
{
b.a = (b.b - a.b) / a.a;
return b;
}
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: 0ms
memory: 3872kb
input:
3 0 0 0 1 0 0 1 0 0 1 1 0
output:
2000000002.00000000
result:
wrong answer