码迷,mamicode.com
首页 > 其他好文 > 详细

Wannafly挑战赛21A

时间:2018-08-04 23:18:51      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:4.0   --   scan   ble   define   void   ||   fine   cst   

题目链接

Wannafly挑战赛21A

题解

代码

#include <cstdio>
#include <cmath>
#define MAX 1000005
#define Pi 3.14159265
 
struct Point{
    double x,y;
    void input() {
        scanf("%lf%lf",&x,&y);
    }
    void output() {
        printf("%f %f\n", x,y);
    }
}p[MAX],s[MAX];
Point XZ(Point* p) {
    return (Point){sin(Pi/4.0)*p->x+sin(Pi/4.0)*p->y, sin(Pi/4.0)*p->x-sin(Pi/4.0)*p->y};
}
 
bool cmp1(Point* a, Point* b) {return a->x<b->x;}
bool cmp2(Point* a, Point* b) {return a->y>b->y;}
bool cmp3(Point* a, Point* b) {return a->y<b->y;}
bool cmp4(Point* a, Point* b) {return a->x>b->x;}
 
int main () {
    int T, n;
    scanf ("%d", &T);
    while (T--){
        scanf("%d",&n);
        for (int i = 0; i < n; i += 1)
            p[i].input();
        for (int i = 0; i < n; i += 1)
            s[i] = XZ(p+i);
        Point *a,*b,*c,*d;
        a=b=c=d=&p[0];
        for (int i = 1; i < n; i += 1){
            if (cmp1(p+i,a))a=p+i;
            if (cmp2(p+i,b))b=p+i;
            if (cmp3(p+i,c))c=p+i;
            if (cmp4(p+i,d))d=p+i;
        }
        if (a==b||a==c||d==b||d==c){
            printf("Yes\n");
            continue;
        }
        a=b=c=d=&s[0];
        for (int i = 1; i < n; i += 1){
            if (cmp1(s+i,a))a=s+i;
            if (cmp2(s+i,b))b=s+i;
            if (cmp3(s+i,c))c=s+i;
            if (cmp4(s+i,d))d=s+i;
        }
        if (a==b||a==c||d==b||d==c){
            printf("Yes\n");
            continue;
        }
        printf("No\n");
    }
    return 0;
}

Wannafly挑战赛21A

标签:4.0   --   scan   ble   define   void   ||   fine   cst   

原文地址:https://www.cnblogs.com/sssy/p/9420339.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!