当前位置:网站首页>uva1325
uva1325
2022-08-05 05:03:00 【Knife stabs the bear】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 1e6 + 7,maxm = 1007;
struct Node {
double len;
int first, second;
bool operator<(const Node& input) {
return len < input.len;
}
}node[maxn];
double x[maxm], y[maxm], z[maxm];
int p[maxm],n,sum[maxm],sum2[maxm];
#define _POW(x) (x) * (x)
//求距离
double GetLen(int a, int b) {
return sqrt(_POW(x[a] - x[b]) + _POW(y[a] - y[b]) + _POW(z[a] - z[b]));
}
//an unstable planet
bool IsInstable(int index) {
//1的个数 与0的个数
int f0 = sum[index] - sum2[index], f1 = sum2[index];
return p[index] ? f1 < f0 : f0 < f1;
}
int main()
{
while (cin >> n) {
int cnt = 0;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i] >> z[i] >> p[i];
sum[i] = 1;
sum2[i] = p[i];
for (int j = 0; j < i; j++) {
node[cnt].first = i;
node[cnt].second = j;
node[cnt].len = GetLen(i, j);
cnt++;
}
}
sort(node, node + cnt);
int c = 0,ans = 0;
double r = 0;
for (int i = 0; i < cnt; i++) {
int first = node[i].first;
int second = node[i].second;
//first second Is it unstable
bool f0 = IsInstable(first);
bool s0 = IsInstable(second);
//总次数
sum[first]++;sum[second]++;
//1的次数
sum2[first] += p[second];
sum2[second] += p[first];
bool f1 = IsInstable(first);
bool s1 = IsInstable(second);
//first second 发生变化了
if (f0 != f1) {
if (f1)c++;
else c--;
}
if (s0 != s1) {
if (s1)c++;
else c--;
}
if (i == cnt - 1 || node[i].len != node[i + 1].len) {
if (c > ans) {
ans = c;
r = node[i].len;
}
}
}
cout << ans << endl;
cout << fixed << setprecision(4) << r << endl;
}
return 0;
}
边栏推荐
猜你喜欢
![[BSidesCF 2019] Kookie](/img/29/19e7c244feb86b37ab32a53aa11f25.png)
[BSidesCF 2019] Kookie

Detailed explanation of each module of ansible

Learning and finishing of probability theory 8: Geometric and hypergeometric distributions

狗仔队:表面编辑多视点图像处理

开发属于自己的node包

动力小帆船制作方法简单,电动小帆船制作方法

u-boot debugging and positioning means

数字孪生技术在电力系统中的应用现状

upload upload pictures to Tencent cloud, how to upload pictures

How to solve complex distribution and ledger problems?
随机推荐
判断语句_switch与case
软件管理rpm
入口点注入
creo怎么测量点到面的距离
【cesium】加载并定位 3D Tileset
2023年信息与通信工程国际会议(JCICE 2023)
The first performance test practice, there are "100 million" a little nervous
电话溥功能
C#关于set()和get()方法的理解及使用
【转】什么是etcd
[cesium] element highlighting
Analyses the mainstream across technology solutions
dedecms报错The each() function is deprecated
u-boot debugging and positioning means
uva1325
NPDP证书含金量高吗?跟PMP相比?
淘宝账号如何快速提升到更高等级
for..in和for..of的区别
span标签和p标签的区别
Flutter学习5-集成-打包-发布