还有一道神奇的暴力(正解是要旋转坐标轴的)
#include<cstdio> #include<cmath> #include<algorithm> using namespace std; template<class T> inline void read(T &_a){ bool f=0;int _ch=getchar();_a=0; while(_ch<'0' || _ch>'9'){if(_ch=='-')f=1;_ch=getchar();} while(_ch>='0' && _ch<='9'){_a=(_a<<1)+(_a<<3)+_ch-'0';_ch=getchar();} if(f)_a=-_a; } struct fff { int x,y,d; bool operator < (const fff xx) const {return d<xx.d;} }node[1001]; int n,cnt,ansx,ansy; inline bool check(int x,int y) { for (register int i=1;i<=n;++i) if(abs(node[i].x-x)+abs(node[i].y-y)!=node[i].d) return false; return true; } int main() { read(n); for (register int i=1;i<=n;++i) read(node[i].x),read(node[i].y),read(node[i].d); for (register int i=0;i<=node[1].d;++i) { if(check(node[1].x+i,node[1].y+(node[1].d-i))) if(cnt==1) {printf("uncertain"); return 0;} else {cnt=1; ansx=node[1].x+i; ansy=node[1].y+(node[1].d-i);}; if(i) if(check(node[1].x-i,node[1].y+(node[1].d-i))) if(cnt==1) {printf("uncertain"); return 0;} else {cnt=1; ansx=node[1].x-i; ansy=node[1].y+(node[1].d-i);}; if(node[1].d-i&&i) if(check(node[1].x+i,node[1].y-(node[1].d-i))) if(cnt==1) {printf("uncertain"); return 0;} else {cnt=1; ansx=node[1].x+i; ansy=node[1].y-(node[1].d-i);}; if(node[1].d-i&&i) if(check(node[1].x-i,node[1].y-(node[1].d-i))) if(cnt==1) {printf("uncertain"); return 0;} else {cnt=1; ansx=node[1].x-i; ansy=node[1].y-(node[1].d-i);}; } if(!cnt) printf("impossible"); else printf("%d %d",ansx,ansy); return 0; }