(I2
I123
I4
(dp0
Vsquares.%l
p1
(V4.cpp
p2
S'#include <bits/stdc++.h>\r\n#define endl \'\\n\'\r\n\r\n#define int long long\r\n\r\nusing namespace std;\r\nconst int MAXN = 2 * (42);\r\nconst int OFF_SET = 442;\r\n\r\nstruct point\r\n{\r\n    int x, y;\r\n    point() {x = -1; y = -1;}\r\n    point(int _x, int _y)\r\n    {\r\n        x = _x;\r\n        y = _y;\r\n    }\r\n};\r\n\r\nstruct square\r\n{\r\n    point a, b, c, d;\r\n    square() {a = point(); b = point(); c = point(); d = point();}\r\n    square(point center, point helper)\r\n    {\r\n        a = helper;\r\n        int delta_x = center.x - a.x, delta_y = center.y - a.y;\r\n\r\n        c = point(center.x + delta_x, center.y + delta_y);\r\n        d = point(center.x + delta_y, center.y - delta_x);\r\n        b = point(center.x - delta_y, center.y + delta_x);\r\n    }\r\n};\r\n\r\nint n;\r\nsquare a[MAXN];\r\n\r\nvoid read()\r\n{\r\n    cin >> n;\r\n\r\n    for(int i = 0; i < n; i++)\r\n    {\r\n        int x, y, cx, cy;\r\n        cin >> x >> y >> cx >> cy;\r\n        a[i] = square(point(x, y), point(cx, cy));\r\n\r\n        cout << "square " << i << endl;\r\n        cout << a[i].a.x << ", " << a[i].a.y << endl;\r\n       cout << a[i].b.x << ", " << a[i].b.y << endl;\r\n        cout << a[i].c.x << ", " << a[i].c.y << endl;\r\n        cout << a[i].d.x << ", " << a[i].d.y << endl;\r\n        cout << endl;\r\n    }\r\n}\r\n\r\nint dist(point a, point b)\r\n{\r\n    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);\r\n}\r\n\r\nbool used[2 * OFF_SET][2 * OFF_SET];\r\n\r\nvoid solve()\r\n{\r\n    int ans = 0;\r\n    for(int i = 0; i < n; i++)\r\n    {\r\n        int mxx, mxy, mnx, mny;\r\n        mxx = max(a[i].a.x, max(a[i].b.x, max(a[i].c.x, a[i].d.x)));\r\n        mxy = max(a[i].a.y, max(a[i].b.y, max(a[i].c.y, a[i].d.y)));\r\n\r\n        mnx = min(a[i].a.x, min(a[i].b.x, min(a[i].c.x, a[i].d.x)));\r\n        mny = min(a[i].a.y, min(a[i].b.y, min(a[i].c.y, a[i].d.y)));\r\n\r\n        //cout << i << " -> {" << mnx << ", " << mxx << "}   {" << mny << ", " << mxy << "}" << endl;\r\n\r\n        for(int d = mnx; d < mxx; d++)\r\n            for(int j = mny; j < mxy; j++)\r\n            {\r\n                //cout << d << " " << j << endl;\r\n                used[OFF_SET + d][OFF_SET + j] = true;\r\n            }\r\n\r\n    }\r\n\r\n    for(int i = 0; i < OFF_SET * 2; i++)\r\n        for(int j = 0; j < OFF_SET * 2; j++)\r\n            ans += used[i][j];\r\n\r\n    cout << ans << endl;\r\n}\r\n\r\n#undef int\r\nint main()\r\n{\r\n    ios_base::sync_with_stdio(false);\r\n    cin.tie(NULL);\r\n\r\n    read();\r\n    solve();\r\n    return 0;\r\n}\r\n\r\n/*\r\n3\r\n-35 45 -50 50\r\n-15 35 -40 20\r\n-40 30 -30 20\r\n*/\r\n\r\n/**\r\n3\r\n15 20 5 30\r\n10 10 5 5\r\n30 20 25 25\r\n**/\r\n'
p3
tp4
stp5
.