当前位置:网站首页>uva1325
uva1325
2022-08-05 04:59:00 【小刀刺大熊】
#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]));
}
//是不稳定星球
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 是否是不稳定的
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;
}
边栏推荐
猜你喜欢

u-boot debugging and positioning means

A 35-year-old software testing engineer with a monthly salary of less than 2W, resigns and is afraid of not finding a job, what should he do?

雷克萨斯lm的安全性到底体现在哪里?一起来看看吧

特征预处理

大学物理---质点运动学

小程序_动态设置tabBar主题皮肤

服务器磁盘阵列
![[Surveying] Quick Summary - Excerpt from Gaoshu Gang](/img/35/e5c5349b8d4ccf9203c432a9aaee7b.png)
[Surveying] Quick Summary - Excerpt from Gaoshu Gang

The production method of the powered small sailboat is simple, the production method of the electric small sailboat

write the story about us
随机推荐
使用IDEA连接TDengine服务器
Qt制作18帧丘比特表白意中人、是你的丘比特嘛!!!
算法---一和零(Kotlin)
[MRCTF2020] PYWebsite
2023年信息与通信工程国际会议(JCICE 2023)
雷克萨斯lm的安全性到底体现在哪里?一起来看看吧
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
The solution to the failure to read channel information when dedecms generates a message in the background
Application status of digital twin technology in power system
Bytebuffer put flip compact clear method demonstration
u-boot中的u-boot,dm-pre-reloc
upload upload pictures to Tencent cloud, how to upload pictures
Mysql's redo log detailed explanation
LAB 信号量实现细节
C语言-大白话理解原码,反码和补码
动力小帆船制作方法简单,电动小帆船制作方法
淘宝账号如何快速提升到更高等级
小程序_动态设置tabBar主题皮肤
u-boot调试定位手段
In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit