Codeforces Round #432 (Div. 1) A.Five Dimensional Points

A. Five Dimensional Points
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.

We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors and is acute (i.e. strictly less than ). Otherwise, the point is called good.

The angle between vectors and in 5-dimensional space is defined as , where is the scalar product and is length of .

Given the list of points, print the indices of the good points in ascending order.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 103) — the number of points.

The next n lines of input contain five integers ai, bi, ci, di, ei (|ai|, |bi|, |ci|, |di|, |ei| ≤ 103)  — the coordinates of the i-th point. All points are distinct.

Output

First, print a single integer k — the number of good points.

Then, print k integers, each on their own line — the indices of the good points in ascending order.

Examples
Input
6
0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
Output
1
1
Input
3
0 0 1 2 0
0 0 9 2 0
0 0 5 9 0
Output
0


题目大意:现在给一个五维坐标。五维是什么样的没人知道。但是坐标是直观的,(1,2,3,4,5)便是一个五维点。

现在给n个这样的点,现在定义good点:以这个点开始与任何两个点相连都不是锐角。

反之如果有任何一组点组成的连线是锐角就是bad点。

这题乍一看只能暴力啊,而且绝对会超时。但是其实没有这么复杂。在二维空间中,保证有一个点是good点的情况是原点一个点,上下左右各一个点一共五个点;

三维空间中,保证一个点是good的情况是原点一个点,上下左右前后各一个点一共7个点。

那么推导可知五维空间要保证有一个good点那么点数不能超过11.

超过11则就放弃治疗直接写0。

没超过11就暴力。


#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;

struct asd{
    int a,b,c,d,e;
    asd(int f=0,int g=0,int h=0,int i=0,int j=0)
    {
        a=f;b=g;c=h;d=i;e=j;
    }
    void read(){
        scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    }
    friend asd operator - (const asd &q, const asd &w);
}p[1024];
asd operator - (const asd &q, const asd &w)
{
        return asd(q.a-w.a , q.b-w.b , q.c-w.c , q.d-w.d , q.e-w.e);
}
int time(const asd& q,const asd &w)
{
    return q.a*w.a+q.b*w.b+q.c*w.c+q.d*w.d+q.e*w.e;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        p[i].read();
    }
    if(n>11){
        cout<<0<<endl;
    }
    else{
        int ans[1023];
        bool yes = true;
        int number =0 ;
        for(int i=0; i<n;i++)
        {
            yes = true;
            asd tem1,tem2;
            for(int j=0;j<n;j++)
            {
                if(j==i) continue;
                for(int k = j+1;k<n;k++){
                    if(k==i) continue;
                    tem1=p[i]-p[j];
                    tem2=p[i]-p[k];
                    if(time(tem1,tem2)>0)
                        yes=0;
                        if(yes==0) break;
                }
                if(yes==0) break;
            }
            if(yes) ans[number++]=i;
        }
        cout<<number<<endl;
        for(int i=0;i<number;i++)
            cout<<ans[i]+1<<endl;
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值