// UVa 11639 - Guard the Land #include <iostream> #include <stdio.h> using namespace std; struct rect { int x1, y1, x2, y2; }; int area(rect c) { return (c.x2 - c.x1) * (c.y2 - c.y1); } int main() { int tt; cin >> tt; for (int t = 1; t <= tt; t++) { rect a, b, c; cin >> a.x1 >> a.y1 >> a.x2 >> a.y2; cin >> b.x1 >> b.y1 >> b.x2 >> b.y2; c.x1 = max(a.x1, b.x1); c.x2 = min(a.x2, b.x2); c.y1 = max(a.y1, b.y1); c.y2 = min(a.y2, b.y2); int strong = (c.x1 < c.x2 && c.y1 < c.y2) ? area(c) : 0; int weak = area(a) + area(b) - (strong << 1); int unsecured = 10000 - weak - strong; printf("Night %d: %d %d %d\n", t, strong, weak, unsecured); } return 0; }
Monday, February 29, 2016
UVa 11639 - Guard the Land
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment