当前位置:网站首页>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;
}
边栏推荐
- After controlling the export file in MySQL, it becomes \N. Is there any solution?
- C language - vernacular to understand the original code, inverse code and complement code
- upload upload pictures to Tencent cloud, how to upload pictures
- 仪表板展示 | DataEase看中国:数据呈现中国资本市场
- 【cesium】元素高亮显示
- Detailed explanation of Mysql's undo log
- 社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
- 浅析主流跨端技术方案
- Detailed explanation of each module of ansible
- C语言-大白话理解原码,反码和补码
猜你喜欢
![[BJDCTF2020] EasySearch](/img/60/464de3bcdda876171b9f61ad31bff1.png)
[BJDCTF2020] EasySearch

Day019 方法重写与相关类的介绍

使用IDEA连接TDengine服务器
![【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】](/img/b5/716627b370e489ccf320a86540f7ba.png)
【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】

University Physics---Particle Kinematics

Excel画图

Flutter learning 2-dart learning

Flutter learning three-Flutter basic structure and principle

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?

基于Web的商城后台管理系统的设计与实现
随机推荐
Redis哨兵模式配置文件详解
There are a lot of 4T hard drives remaining, prompting "No space left on device" insufficient disk space
Excel Paint
关于sklearn库的安装
How can Flutter parent and child components receive click events
ansible各个模块详解
Flutter学习-开篇
Detailed explanation of each module of ansible
mysql数据库表什么字段类型的存储长度最大?
【软考 系统架构设计师】软件架构设计③ 特定领域软件架构(DSSA)
使用IDEA连接TDengine服务器
Four-digit display header design
延迟加载js方式async与defer区别
University Physics---Particle Kinematics
Flutter学习三-Flutter基本结构和原理
The log causes these pits in the thread block, you have to guard against
请写出SparkSQL语句
Visibility of multi-column attribute column elements: display, visibility, opacity, vertical alignment: vertical-align, z-index The larger it is, the more it will be displayed on the upper layer
Bytebuffer put flip compact clear method demonstration
How to identify false evidence and evidence?