当前位置:网站首页>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;
}
边栏推荐
- C+ +核心编程
- 【cesium】3D Tileset 模型加载并与模型树关联
- [8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
- overloaded operator
- 【学习笔记之菜Dog学C】动态内存管理之经典笔试题
- There are a lot of 4T hard drives remaining, prompting "No space left on device" insufficient disk space
- Cron(Crontab)--use/tutorial/example
- 服务器磁盘阵列
- C语言-大白话理解原码,反码和补码
- MySQL中控制导出文件后变为了\N有什么解决方案吗?
猜你喜欢

App rapid development and construction experience: the importance of small programs + custom plug-ins
![[cesium] 3D Tileset model is loaded and associated with the model tree](/img/03/50b7394f33118c9ca1fbf31b737b1a.png)
[cesium] 3D Tileset model is loaded and associated with the model tree

Mysql's redo log detailed explanation

C+ +核心编程

ansible各个模块详解

【cesium】3D Tileset 模型加载并与模型树关联

Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource

Flutter learning 5-integration-packaging-publish

Dephi逆向工具Dede导出函数名MAP导入到IDA中

Flutter learning 2-dart learning
随机推荐
for..in和for..of的区别
How does the Flutter TapGestureRecognizer work
Cryptography Series: PEM and PKCS7, PKCS8, PKCS12
bytebuffer internal structure
C语言-大白话理解原码,反码和补码
Day14 jenkins deployment
仪表板展示 | DataEase看中国:数据呈现中国资本市场
How to solve complex distribution and ledger problems?
结构光三维重建(二)线结构光三维重建
In the WebView page of the UI automation test App, the processing method when the search bar has no search button
University Physics---Particle Kinematics
机器学习概述
dedecms dream weaving tag tag does not support capital letters fix
C++ core programming
Flutter学习2-dart学习
Bytebuffer put flip compact clear method demonstration
算法---一和零(Kotlin)
Mvi架构浅析
8.04 Day35-----MVC三层架构
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]