当前位置:网站首页>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;
}
边栏推荐
- 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?
- 2023年信息与通信工程国际会议(JCICE 2023)
- Excel画图
- 特征预处理
- span标签和p标签的区别
- Application status of digital twin technology in power system
- dedecms织梦tag标签不支持大写字母修复
- [cesium] 3D Tileset model is loaded and associated with the model tree
- 判断语句_switch与case
- [SWPU2019]Web1
猜你喜欢
Flutter learning three-Flutter basic structure and principle
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
Learning and finishing of probability theory 8: Geometric and hypergeometric distributions
Qt制作18帧丘比特表白意中人、是你的丘比特嘛!!!
Mysql的undo log详解
基于Web的商城后台管理系统的设计与实现
How to solve complex distribution and ledger problems?
Dephi reverse tool Dede exports function name MAP and imports it into IDA
dedecms后台生成提示读取频道信息失败的解决方法
JeeSite New Report
随机推荐
作业8.4 进程间的通信 管道与信号
C#关于set()和get()方法的理解及使用
MySQL基础(一)---基础认知及操作
【学习笔记之菜Dog学C】动态内存管理之经典笔试题
为什么刚考完PMP,就开始准备软考了?
Day019 Method overriding and introduction of related classes
How to identify false evidence and evidence?
bytebuffer use demo
Qt制作18帧丘比特表白意中人、是你的丘比特嘛!!!
Flutter 父子组件如何都能收到点击事件
Flutter TapGestureRecognizer 如何工作
flink reads mongodb data source
结构光三维重建(一)条纹结构光三维重建
[MRCTF2020] PYWebsite
[CISCN2019 South China Division]Web11
overloaded operator
uboot enable debug printing information
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
C language - vernacular to understand the original code, inverse code and complement code
Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource