problem USACO
My code
struct Rect{
ll x1, x2, y1, y2;
ll area(){ return abs((x2 - x1)*(y2 - y1));}
};
ll inter(Rect a, Rect b){
ll x = max(0, min(a.x2, b.x2) - max(a.x1, b.x1));
ll y = max(0, min(a.y2, b.y2) - max(a.y1, b.y1));
// more than one corner.
if(x == (a.x2 - a.x1) || y == (a.y2 - a.y1)){
return x*y;
}
return 0;
}
int main(){
Rect a, b;
cin >> a.x1 >> a.y1 >> a.x2 >> a.y2;
cin >> b.x1 >> b.y1 >> b.x2 >> b.y2;
cout << a.area() - inter(a, b) << '\n';
}
Passed all test except the fourth one.