White Sheet (矩形面积模板) (Codeforces Round #587 (Div. 3) )
Posted shallow-dream
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了White Sheet (矩形面积模板) (Codeforces Round #587 (Div. 3) )相关的知识,希望对你有一定的参考价值。
#include <iostream> #include <vector> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; struct Rect { ll x1, y1, x2, y2; ll area() const { if (x2 < x1 || y2 < y1) return 0; else return (x2 - x1) * (y2 - y1); } }; Rect its(Rect a, Rect b) { Rect res; res.x1 = max(a.x1, b.x1); res.x2 = min(a.x2, b.x2); res.y1 = max(a.y1, b.y1); res.y2 = min(a.y2, b.y2); return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); Rect w, b1, b2; cin >> w.x1 >> w.y1 >> w.x2 >> w.y2; cin >> b1.x1 >> b1.y1 >> b1.x2 >> b1.y2; cin >> b2.x1 >> b2.y1 >> b2.x2 >> b2.y2; ll res = w.area() - its(w, b1).area() - its(w, b2).area() + its(w, its(b1, b2)).area(); if (res > 0) cout << "YES "; else cout << "NO "; }
以上是关于White Sheet (矩形面积模板) (Codeforces Round #587 (Div. 3) )的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #587 (Div. 3) C - White Sheet
luogu5490POJ1151模板扫描线 /Atlantis (求矩形面积并)