C. Five Dimensional Points
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
Note
In the first sample, the first point forms exactly a angle with all other pairs of points, so it is good.
In the second sample, along the cd plane, we can see the points look as follows:
We can see that all angles here are acute, so no points are good.
这道题就是问你在五维空间中有没有点和其他任意不重合的两点都构不成锐角,看上去挺吓人的,其实直接暴力就行,判断是否是锐角,就用向量积判断就行,如果是锐角,向量积就大于0,这个也可以用余弦公式:
求得,当值大于0的时候就是锐角
#include<bits/stdc++.h>
using namespace std;
using LL =int64_t;
struct Node {
LL a[5];
}s[1005];
bool book[1005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
int sum=n;
memset(book,false,sizeof(book));
for(int i=0;i<n;i++)
for(int j=0;j<5;j++)
cin>>s[i].a[j];
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
if(i==j) continue;
for(int k=1;k<n;k++){
if(i==k||j==k) continue;
LL ans=0;
for(int x=0;x<5;x++) {
ans+=(s[j].a[x]-s[i].a[x])*(s[k].a[x]-s[i].a[x]);
}
if(ans>0) {
book[i]=true;
sum--;
j=n;k=n;
}
}
}
}
cout<<sum<<endl;
if(sum>0) {
for(int i=0;i<n;i++) {
if(book[i]==false) cout<<i+1<<" ";
}
cout<<endl;
}
return 0;
}