题意:在w*h的方格内,找出一个最大的正方形,使得正方形内没有点(可以在边界有点)。
思路:枚举。正方形可以看作是矩形,只不过在取的时候取最短的那条边作为边长,那么枚举出短边最大的矩形即可。
code:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF=0x3fffffff;
const int inf=-INF;
const int N=1000000;
const int M=105;
const int mod=1000000007;
const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define cpy(x,a) memcpy(x,a,sizeof(a))
#define fr(i,s,n) for (int i=s;i<=n;i++)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt rt<<1
#define rrt rt<<1|1
#define middle int m=(r+l)>>1
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define mk make_pair
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);struct node
{int x,y;
}g[M];
int y[M];bool cmp(node a,node b)
{if (a.x==b.x) return a.y<b.y;return a.x<b.x;
}
int main()
{int T,n,w,h;scanf("%d",&T);while (T--){scanf("%d %d %d",&n,&w,&h);fr(i,0,n-1){scanf("%d %d",&g[i].x,&g[i].y);y[i]=g[i].y;}y[n]=0;y[n+1]=h;sort(y,y+n+2);sort(g,g+n,cmp);int ans=0,sx,sy;int m=unique(y,y+n+2)-y;fr(i,0,m-1) for (int j=i+1;j<m;j++){int th=y[j]-y[i],p=0,tw;fr(k,0,n-1){if (g[k].y<=y[i]||g[k].y>=y[j]) continue;tw=g[k].x-p;if (ans<min(th,tw)){ans=min(th,tw);sx=p;sy=y[i];}p=g[k].x;}tw=w-p;if (ans<min(th,tw)){ans=min(th,tw);sx=p;sy=y[i];}}printf("%d %d %d\n",sx,sy,ans);if (T) puts("");}
}