Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) C. Five Dimensional Points 暴力
链接:
http://codeforces.com/contest/851/problem/C
题意:
有n个五维的点,求有多少个“好“点,对于“好”点、“坏”点的定义如下:
“好”点:设该点为a,在所给点中任意两个不相等且不为a的点b,c,向量ab与向量bc的夹角均不为锐角。
“坏”点:不是“好”点的点都是“坏”点
思路:
可以从二维三维的方向来考虑,在二维中,一个“好”点的周围最多有4个点(x正负方向两个,y正负方向两个),三维则有6个(加上z方向上两个),可以知道,五维的情况下,一个“好”点周围最多有10个点,加上自身,即图中有“好”点的情况下,最多有11个点,即n>11时不可能存在“好”点,然后n<=11的情况就枚举一下就行了。
代码:
31 struct Point { 32 double a, b, c, d, e; 33 }p[MAXN]; 34 35 const double operator*(Point &x, Point &y) { 36 return x.a*y.a + x.b*y.b + x.c*y.c + x.d*y.d + x.e*y.e; 37 } 38 39 const Point operator-(Point &x, Point &y) { 40 return Point{ x.a - y.a,x.b - y.b,x.c - y.c,x.d - y.d,x.e - y.e }; 41 } 42 43 int main() { 44 ios::sync_with_stdio(false), cin.tie(0); 45 int n; 46 cin >> n; 47 rep(i, 0, n) cin >> p[i].a >> p[i].b >> p[i].c >> p[i].d >> p[i].e; 48 if (n > 11) return (cout << 0 << endl), 0; 49 if (n == 1) return (cout << 1 << endl << 1), 0; 50 if (n == 2) return (cout << 2 << endl << "1 2"), 0; 51 VI ans; 52 rep(i, 0, n) { 53 int fg = 1; 54 rep(j, 0, n) rep(k, 0, n) { 55 if (i == j || j == k || k == i) continue; 56 Point AB = p[j] - p[i]; 57 Point AC = p[k] - p[i]; 58 if (AB*AC > 0) fg = 0; 59 } 60 if (fg) ans.pb(i + 1); 61 } 62 cout << ans.size() << endl; 63 rep(i, 0, ans.size()) cout << ans[i] << ' '; 64 return 0; 65 }