zoukankan      html  css  js  c++  java
  • 还有一道神奇的暴力(正解是要旋转坐标轴的)

    #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;
    }
  • 相关阅读:
    java调用本地默认浏览器
    spark入门(helloworld插件)
    Android下 布局加边框 指定背景色 半透明
    Android下Fragment使用(全集)
    Android下的broadcast
    Android 下Service
    Android实用工具
    CSDN云盘资源
    Codeforces Round #201 (Div. 2). E--Number Transformation II(贪心)
    Codeforces Round #201.C-Alice and Bob
  • 原文地址:https://www.cnblogs.com/jaywang/p/7773978.html
Copyright © 2011-2022 走看看