본문 바로가기

USACO/Bronze

백준 18786 Triangles (USACO February 2020 Bronze 1번)

문제 링크: https://www.acmicpc.net/problem/18786

 

18786번: Triangles (Bronze)

Posts at $(0,0)$, $(1,0)$, and $(1,2)$ form a triangle of area $1$. Thus, the answer is $2\cdot 1=2$. There is only one other triangle, with area $0.5$.

www.acmicpc.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <bits/stdc++.h>
using namespace std;
 
struct coord {
    int x, y;
};
int n;
coord p[101];
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> p[i].x >> p[i].y;
 
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                if(i == j || i == k || j == k) continue;
                if(p[i].x == p[j].x && p[i].y == p[k].y)
                    ans = max(ans, abs(p[i].y - p[j].y) * abs(p[i].x - p[k].x));
            }
        }
    }
 
    cout << ans << '\n';
    return 0;
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter