ACHTUNG: there are as usual some underwater shitstones by SPOJ lamers, the test input file seems to be containing some garbage symbols etc. So we are forced to write in damned C++ (with sets).
#include <cstdio>
#include <cstdlib>
#include <set>
#include <algorithm>
using namespace std;
int cases, n, h, w, x, y, i, j, bestx, besty, dist, prev;
set<int> xs, ys;
set<int>::iterator it;
char scheisse;
int main() {
scanf("%d%c", &cases, &scheisse);
while(cases--) {
scanf("%d %d %d%c", &w, &h, &n, &scheisse);
for(i = 0; i < n; i++) {
scanf("%d %d%c", &x, &y, &scheisse);
xs.insert(x);
ys.insert(y);
}
xs.insert(w+1), ys.insert(h+1);
bestx = besty = 0;
prev = 0;
for(it = xs.begin(); it != xs.end(); it++) {
dist = (*it) - prev - 1;
bestx = max(dist, bestx);
prev = (*it);
}
prev = 0;
for(it = ys.begin(); it != ys.end(); it++) {
dist = (*it) - prev - 1;
besty = max(dist, besty);
prev = (*it);
}
printf("%d\n", (bestx*besty));
xs.clear(), ys.clear();
}
}
No comments:
Post a Comment