WCE0004 - Editorial

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mod 1000000007
#define f first
#define s second
#define pb push_back

int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll tc;
cin>>tc;
while(tc–)
{
ll r,c,no_e;
cin>>r>>c>>no_e;
vectorx;
vectory;
for(ll i=0;i<no_e;i++)
{
ll ele;
cin>>ele;
x.pb(ele);
cin>>ele;
y.pb(ele);
}
x.pb(0);x.pb(r+1);
y.pb(0);y.pb(c+1);
sort(x.begin(),x.end());
sort(y.begin(),y.end());
ll x_max = x[1]-x[0];
ll y_max = y[1]-y[0];
for(ll i=1;i<x.size()-1;i++)
{
x_max = max(x_max , x[i+1]-x[i]);
}
for(ll i=1;i<y.size()-1;i++)
{
y_max = max(y_max , y[i+1]-y[i]);
}
// cout<<x_max<<’ '<<y_max<<"\n";
cout<<(x_max-1)*(y_max-1)<<"\n";

}

}