Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么wa。。大牛们帮小弟看一下。。。谢了#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <cstring> using namespace std; const int maxn=2001; int S,H; struct point{ int x,y; }P[maxn],A[maxn],ans[maxn]; bool flag[maxn][maxn]; bool judge(point a,double R){ if(a.x+R>S||a.x-R<0||a.y+R>S||a.y-R<0) return true; else return false; } int dist(point a,point b){ return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } int cmp(point a,point b){ return (a.x<b.x||(a.x==b.x&&a.y<b.y)); } int main(){ // freopen("in.txt","r",stdin); int n; scanf("%d",&n); while(n--){ memset(flag,false,sizeof(flag)); while(scanf("%d%d",&S,&H)!=EOF){ for(int i=0;i<H;++i){ scanf("%d%d",&P[i].x,&P[i].y); flag[P[i].x][P[i].y]=true; } long long id=0; for(int i=0;i<=S;++i){ for(int j=0;j<=S;++j){ if(flag[i][j]==false){ A[id].x=i,A[id].y=j; id++; } } } int radius=0; int index=0; for(int i=0;i<id;++i){ for(int j=1;j<H;++j){ radius=max(dist(A[i],P[j]),dist(A[i],P[j-1])); } if(!judge(A[i],sqrt((double)radius))) ans[index++]=A[i]; else continue; } if(index==0) printf("poodle\n"); else{ sort(ans,ans+index,cmp); printf("%d %d\n",ans[0].x,ans[0].y); } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator