-
Notifications
You must be signed in to change notification settings - Fork 0
/
DEFKIN.cpp
43 lines (34 loc) · 976 Bytes
/
DEFKIN.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// https://www.spoj.com/problems/DEFKIN/
/*
Sort x co-ordinate and y co-ordinate of tower and then find delta(x) and delta(y).
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int w,h,n;
cin>>w>>h>>n;
vector<int> x, y; // vector of x and y coordinates
x.push_back(0);
y.push_back(0);
for(int i=0;i<n;i++){
int xcord, ycord;
cin>>xcord>>ycord;
x.push_back(xcord);
y.push_back(ycord);
}
x.push_back(w+1);
y.push_back(h+1);
sort(x.begin(),x.end());
sort(y.begin(),y.end());
int dx = INT_MIN, dy = INT_MIN ; // maximum delta x and delta y
for(int i=1;i<=n+1;i++){
dx = max(dx , x[i] - x[i-1]);
dy = max(dy , y[i] - y[i-1]);
}
cout<<(dx-1)*(dy-1)<<endl;
}
return 0;
}