USACO/Bronze
백준 14173 Square Pasture (USACO December 2016 Bronze 1번)
ssam..
2020. 2. 28. 03:35
문제 링크: https://www.acmicpc.net/problem/14173
14173번: Square Pasture
In the example above, the first original rectangle has corners (6,6) and (8,8). The second has corners at (1,8) and (4,9). By drawing a square fence of side length 7 with corners (1,6) and (8,13), the original areas can still be enclosed; moreover, this is
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
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int x = 11, y = 11, xx = -1, yy = -1;
for(int i = 0; i < 2; i++) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
x = min(x, min(x1, x2));
y = min(y, min(y1, y2));
xx = max(xx, max(x1, x2));
yy = max(yy, max(y1, y2));
}
int ans = xx - x > yy - y ? (xx - x) * (xx - x) : (yy - y) * (yy - y);
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|