From 08258103a1dcdbbb00c7451312b068c95ae1b7f4 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Thu, 18 Nov 2021 13:40:54 -0600 Subject: [PATCH] Attempt basic Square Pasture script --- usaco/Square Pasture/index.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 usaco/Square Pasture/index.cpp diff --git a/usaco/Square Pasture/index.cpp b/usaco/Square Pasture/index.cpp new file mode 100644 index 0000000..cd7788c --- /dev/null +++ b/usaco/Square Pasture/index.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; + +int main() { + freopen("square.in", "r", stdin); + freopen("square.in", "w", stdout); + + int x1, y1, x2, y2; + cin >> x1, y1, x2, y2; + int a1, b1, a2, b2; + cin >> a1, b1, a2, b2; + + int min_x, min_y, max_x, max_y; + min_x = min(min(x1, x2), min(a1, a2)); + min_y = min(min(y1, y2), min(b1, b2)); + max_x = max(min(x1, x2), min(a1, a2)); + max_y = max(min(y1, y2), min(b1, b2)); + + int x_len = max_x - min_x; + int y_len = max_y - min_y; + + cout << x_len * y_len << endl; +}