【Codeforces Round #432 (Div. 1) A】 Five Dimensional Points
2024-08-31 19:50:05
【链接】点击打开链接
【题意】
给你n个5维的点。
然后让你以其中的某一个点作为起点a。
另选两个点b,c.
组成向量a->b,a->c
如果所有的a->b和a->c的夹角都是钝角或直角。则称a这个点good.
否则bad.
让你输出所有为good的点。
【题解】
考虑二维空间里面的一个点a.
那么假设另外还有5个点的话。
是没有办法所有组成的角都是钝(直)角的。
因为只有两个不同象限(或在坐标轴上)的点,和它组成角,才可能组成≥90°的角。
(这里象限是说,以这个点a为原点,画一个坐标系)
也就是如果一个点为good的话,其他的点的个数绝对不能超过4个。(4个象限嘛。。)
那么也就是说,如果n大于一定的范围,是肯定无解的(这里是5维空间,就不是刚才说的4了).
具体的。
你就选一个n^3不会超时的n,然后大于这个数字,就直接输出无解就好。
小于n的话,就暴力做。
【错的次数】
0
【反思】
除非全是xx否则不是good的。
因为中间只要有一个不满足就可以直接break.
可能都有优化方法?
看起来没办法优化时间。
就要从n考虑了。
是不是它能缩小?
是不是它是没有用的?
【代码】
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <cstdlib>
#include <cmath>
#include <bitset>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
#define ld long double
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rf(x) scnaf("%lf",&x)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
#define sz(x) ((int) x.size())
#define ld long double typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //mt19937 myrand(time(0));
//int get_rand(int n){return myrand()%n + 1;}
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e3; struct abc{
int d[6];
}; int n;
LL b[N+10][6];
abc temp1,temp2;
vector <LL> v; LL cal(abc temp1,abc temp2){
LL ju = 0;
rep1(i,1,5)
ju += temp1.d[i]*temp2.d[i];
return ju;
} int main(){
//Open();
//Close();
ri(n);
rep1(i,1,n)
rep1(j,1,5)
rl(b[i][j]);
if (n>250){
puts("0");
}else{
rep1(i,1,n){
bool ok = true;
rep1(j,1,n){
if (i==j) continue;
if (!ok) break;
rep1(l,1,5) temp1.d[l] = b[j][l]-b[i][l];
rep1(k,1,n){
if (j==k || i==k) continue;
rep1(l,1,5){
temp2.d[l] = b[k][l]-b[i][l];
}
if (cal(temp1,temp2)>0) {
ok = false;
break;
}
} }
if (ok){
v.pb(i);
}
}
oi(sz(v));puts("");
rep1(i,0,sz(v)-1){
oi(v[i]),puts("");
}
}
return 0;
}
最新文章
- Struts2自定义拦截器
- Java设计模式-抽象工厂模式(Abstract Factory )
- HTML-web storage
- Docker学习总结之docker介绍
- 右下角弹出";Windows-延缓写入失败";或者";xxx-损坏文件 请运行Chkdsk工具";
- oracle中in与exists的区别
- 第五篇、iOS常用的工具 app icon 、office文件格式互转、在线HTML编辑器、16、10进制互转
- sql之事务和并发
- 【24】若所有参数皆需类型转换,请为此采用non-members函数
- 帝国cms 列表页分页样式修改美化【2】
- bootstrap2.3.2常用标签的使用
- Windows Server 架设VPN要点
- 回顾曾经的自己,献给java初学者的建议
- 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution
- 使用 Composer 安装Laravel扩展包的几种方法
- Ubuntu 16.04 LTS network DIASBLED解决办法
- SimpleDateFormat转换时间,12,24时间格式[转]
- Python 学习第二章
- IT简历
- tail 命令