Checklist
Make sure to read all of How to ask for help on a problem before asking for help.
Problem Info
Blocked Billboard 2
http://www.usaco.org/index.php?page=viewproblem2&cpid=783
My Work
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void freeme(string s){
freopen((s+".in").c_str() , "r" , stdin);
freopen((s+".out").c_str() , "w" , stdout);
}
void solve(){
ll bl_x , bl_y , tr_x , tr_y , bl_x1 , bl_y1 , tr_x1 , tr_y1;
cin>>bl_x>>bl_y>>tr_x>>tr_y>>bl_x1>>bl_y1>>tr_x1>>tr_y1;
bl_x+=1000;
bl_x1+=1000;
bl_y+=1000;
bl_y1+=1000;
tr_x+=1000;
tr_x1+=1000;
tr_y1+=1000;
tr_y+=1000;
ll area = abs(tr_x - bl_x)*abs(tr_y-bl_y);
vector<ll> intersect{max(bl_x , bl_x1) , max(bl_y , bl_y1) , min(tr_x , tr_x1) ,min(tr_y , tr_y1)};
ll area2 = max(intersect[2]-intersect[0] ,0ll)*max(0ll ,intersect[3]-intersect[1]);
if(((tr_x - bl_x)==(intersect[2]-intersect[0]) || (tr_y - bl_y)==(intersect[3]-intersect[1]))){
area-=abs(area2);
}
cout << area <<endl;
}
int main(){
#ifndef himanshu
freeme("billboard");
#endif
int t=1;
//cin>>t;
while(t--){
solve();
}
}
I don’t why is this not working. I have tried so many times. It is stuck on test case 4