H - Windmill Animation

/*
    赛后ZC AC,做两个射线,判断一下偏移角和点在射线的方向即可。
    感觉挺水的.....
    比赛的时候没写出来....
    态度很重要....
*/

#include <cstdio>
#include <iostream>
#include <cmath>
#define pi 3.1415926
using namespace std;

int t,m,s,I;
double A;

int i,j;
struct Point{
    double x;
    double y;
}P[30],b,a,ta;

double dis(Point a){
    return sqrt(a.x*a.x+a.y*a.y);
}

double dmu(Point aa,Point bb){
    return aa.x*bb.x+aa.y*bb.y;
}

double xmu(Point aa,Point bb){
    return aa.x*bb.y-aa.y*bb.x;
}

int main(){
    cin>>t;
    int nca;
    int o;
    while(t--){
        scanf("%d%d%d%d%lf",&nca,&m,&s,&I,&A);
        for(i=1;i<=m;i++)
            scanf("%d%lf%lf",&j,&P[i].x,&P[i].y);
        double fd=(A/180.0)*pi;
        a.x=cos(fd);
        a.y=sin(fd);
        b.x=-a.x;
        b.y=-a.y;
        o=I;
        int ans;
        printf("%d ",nca);
        int f=0;
        for(j=1;j<=s;j++){
            double M=-360.0;
            //printf("oa:%.1lf %.1lf ob:%.1lf %.1lf\n",a.x,a.y,b.x,b.y);
            for(i=1;i<=m;i++){
                if(i==o || i==I) continue;

                ta.x=P[i].x-P[I].x;
                ta.y=P[i].y-P[I].y;

                double tt=xmu(a,ta);
                //printf("ta:%.1lf %.1lf\n",ta.x,ta.y);
                if(tt>0){
                    double cdu=dmu(a,ta)/dis(a)/dis(ta);
                    //puts("1");
                    if(M<cdu){
                        M=cdu;
                        f=1;
                        ans=i;
                    }
                }
                else if(tt<0){
                    double cdu=dmu(b,ta)/dis(b)/dis(ta);
                    if(M<cdu){
                        M=cdu;
                        f=2;
                        ans=i;
                    }
                }
            }
            o=I;
            I=ans;
            if(j!=s)
                printf("%d ",ans);
            else
                printf("%d\n",ans);
            if(f==1)
            {
                b.x=P[o].x-P[I].x;
                b.y=P[o].y-P[I].y;
                a.x=-b.x;
                a.y=-b.y;
            }
            else
            {
                a.x=P[o].x-P[I].x;
                a.y=P[o].y-P[I].y;
                b.x=-a.x;
                b.y=-a.y;
            }
        }

    }
}

/*
2
1 5 5 1 45
1 -1 1
2 1 1
3 0 0
4 -1 -2
5 1 -2
*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值