Below code does is showing wrong output for sample test cases.
Problem Link:
Code:
#include "bits/stdc++.h"
#define ll long long int
using namespace std;
int main()
{
ll t;
cin >> t;
while (t--)
{
ll width, height, n;
cin >> width >> height >> n;
if (n == 0)
{
cout << height * width << endl;
continue;
}
vector<ll> coordinatesX(n);
vector<ll> coordinatesY(n);
for (ll i = 0; i < n; i++)
{
cin >> coordinatesX[i];
cin >> coordinatesY[i];
}
coordinatesX.push_back(width + 1);
coordinatesY.push_back(height + 1);
ll maxwidth = coordinatesX[0] - 1;
ll maxheight = coordinatesY[0] - 1;
sort(coordinatesX.begin(), coordinatesX.end());
sort(coordinatesY.begin(), coordinatesY.end());
for (ll i = 1; i <= n; i++)
{
maxwidth = max(coordinatesX[i] - coordinatesX[i - 1] - 1, maxwidth);
maxheight = max(coordinatesY[i] - coordinatesY[i - 1] - 1, maxheight);
}
cout << maxwidth * maxheight << endl;
}
return 0;
}