poj2059

来源:互联网 发布:网络段子里的老司机 编辑:程序博客网 时间:2024/05/17 06:57

#include<iostream>#include<cmath>using namespace std;

struct Hatch{ int x,y;}hatch[51];int n;int s,h;int flag ;

void input(){ cin>>s>>h; for(int i = 0;i < h;i++) {  cin>>hatch[i].x>>hatch[i].y; }}bool distance(int x,int y){ int dis = 0,mmax = 0; for(int i = 0;i < h;i++) {  if((x == hatch[i].x ) && (y == hatch[i].y))   return false;  else  {   dis = (hatch[i].x - x)*(hatch[i].x - x) + (hatch[i].y - y)*(hatch[i].y - y);      if(mmax < dis)      mmax = dis;  } } if(x*x >= mmax && y*y >= mmax&& (s-x)*(s-x) >= mmax && (s-y)*(s-y) >= mmax && mmax > 0) {  cout<<x<<" "<<y<<endl;  return true; } return false;

}void solve(){  flag = 0; for(int i = 0;i <= s;i++) {  for(int j = 0;j <= s;j++)  {   if(distance(i,j))   {    flag = 1;    break;   }

  }  if(flag)   break; } if(!flag)  cout<<"poodle"<<endl;}int main(){ cin>>n; while(n--) {  input();  solve(); } return 0;}