Codeforces Round #432 C. Five Dimensional Points
来源:互联网 发布:网狐棋牌源码 编辑:程序博客网 时间:2024/05/19 18:43
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;}
- Codeforces Round #432 C. Five Dimensional Points
- Codeforces Round #432 (Div. 2) C Five Dimensional Points
- Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)C. Five Dimensional Points
- Codeforces Round #432 (Div. 1) A.Five Dimensional Points
- Codeforces Round #432 (Div. 2) C 850A Five Dimensional Points(思维)
- Codeforces Round #432 Div. 2 C. Five Dimensional Points(数学)
- codeforces 851C C. Five Dimensional Points
- Five Dimensional Points CodeForces
- codeforces 851 #432 div2 C Five Dimensional Points
- codeforces 851 C (Div#432) Five Dimensional Points
- codeforces 851C Five Dimensional Points 鸽巢定理
- Codeforces 851C . Five Dimensional Points 计算几何,结论
- Codeforces 851 C Five Dimensional Points(数学概念优化)
- - Five Dimensional Points(暴力)
- Codeforces 850 A. Five Dimensional Points(暴力/抽屉定理)
- codeforces851C. Five Dimensional Points(暴力/思维)
- codeforce 850A Five Dimensional Points(特殊判别)
- Codeforces Round #191 (Div. 2) C magic five
- Android6.0获取进程和进程数目的方法
- java集合LinkedList的底层实现源码详解
- Python简明教程(一)数据类型、逻辑控制、函数
- 扬州游记_2017
- Win10 去掉桌面快捷方式小箭头
- Codeforces Round #432 C. Five Dimensional Points
- hdu 4763 kmp的简单应用
- Java设计模式之抽象工厂模式
- 利用TensorFlow实现VGG16
- 常见的HTTP相应状态码
- 什么是协方差矩阵?
- JAVA在win10环境下配置环境变量
- Java经典面试题(其一)——Java异常和克隆
- js页面加载触发事件