QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#373533 | #3663. The Biggest Triangle | Moga | WA | 0ms | 3744kb | C++14 | 1.7kb | 2024-04-01 19:55:51 | 2024-04-01 19:55:52 |
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 double ld;
using namespace std;
int n, t = 1, k;
struct point {
ld a, b;
};
vector<point>v;
point equ(ld x, ld y, ld a, ld b) {
point cur;
if (x == a) {
cur.a = LDBL_MAX;
cur.b = x;
}
else {
cur.a = (b - y) / (a - x);
cur.b = y - cur.a * x;
}
return cur;
}
point inter(point a, point b) {
if (a.a == b.a)
{
a.a = LDBL_MAX;
return a;
}
point x;
x.a = (b.b - a.b) / (a.a - b.a);
x.b = (x.a * a.a) + a.b;
return x;
}
ld clc(point a, point b) {
return abs(sqrtl((a.a - b.a) * (a.a - b.a) + (a.b - b.b) * (a.b - b.b)));
}
ld area(point a, point b, point c) {
return clc(a, b) + clc(b, c) + clc(a, c);
}
void go() {
cin >> n;
for (int i = 0;i < n;i++) {
ld x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
v.push_back(equ(x1, y1, x2, y2));
}
ld ans = -1;
for (int i = 0;i < n;i++) {
for(int j = 0;j < n;j++) {
if(i!=j)
for (int k = 0;k < n;k++) {
if (k != i && j != k) {
point f1 = inter(v[i], v[j]), f2 = inter(v[k], v[j]), f3 = inter(v[i], v[k]);
if (f1.a == LDBL_MAX || f2.a == LDBL_MAX || f3.a == LDBL_MAX)continue;
ans = max(ans, area(f1, f2, f3));
}
}
}
}
if (ans > 0)
cout << ans;
else
cout << "no triangle";
}
int main()
{
MOGA
// cin >> t;
for (int i = 1;i <= t;i++)
{
go();
cout << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3744kb
input:
3 0 0 0 1 0 0 1 0 0 1 1 0
output:
no triangle
result:
wrong answer