# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
456459 | Blistering_Barnacles | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define n1 "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
const int N=2e7;
const ll inf=1e18 ;
const ll mod = 1e9+7 ;
struct ali {
ll x1, y1, x2, y2;
ll ar() { return (y2 - y1) * (x2 - x1); }
};
ll add(ali p, ali q) {
ll fi = max(0ll, min(p.x2, q.x2) - max(p.x1, q.x1));
ll se = max(0ll, min(p.y2, q.y2) - max(p.y1, q.y1));
return fi * se ;
}
ali add2(ali p, ali q) {
ll o = min(p.x2, q.x2) , t = max(p.x1, q.x1) , th = min(p.y2, q.y2) , f = max(p.y1, q.y1) ;
ll fi = max(0ll, min(p.x2, q.x2) - max(p.x1, q.x1));
ll se = max(0ll, min(p.y2, q.y2) - max(p.y1, q.y1));
if(fi * se > 0)
return {o , th , t , f} ;
return { -1 , -1 , -1 , -1} ;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ali one , two , three ;
cin >> one.x1 >> one.y1 >> one.x2 >> one.y2 ;
cin >> two.x1 >> two.y1 >> two.x2 >> two.y2 ;
cin >> three.x1 >> three.y1 >> three.x2 >> three.y2 ;
ali e = add2(two , three) ;
ll r = add(e , one) ;
r = max(r , 0ll) ;
ll q = one.ar() + r - add(one , two) - add(one , three) ;
//cout << q << endl ;
if(q > 0){
cout << "YES" << endl ;
}
else
cout << "NO" << endl ;
return 0 ;
}