当前位置:网站首页>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;
}
边栏推荐
- 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?
- Qt制作18帧丘比特表白意中人、是你的丘比特嘛!!!
- Redis - 13. Development Specifications
- Four-digit display header design
- About the installation of sklearn library
- JeeSite New Report
- 8.04 Day35-----MVC三层架构
- MySQL Foundation (1) - Basic Cognition and Operation
- Homework 8.4 Interprocess Communication Pipes and Signals
- 【学生毕业设计】基于web学生信息管理系统网站的设计与实现(13个页面)
猜你喜欢
随机推荐
MySQL中控制导出文件后变为了\N有什么解决方案吗?
Use IDEA to connect to TDengine server
开发属于自己的node包
基于Web的商城后台管理系统的设计与实现
After controlling the export file in MySQL, it becomes \N. Is there any solution?
mysql数据库表什么字段类型的存储长度最大?
How can Flutter parent and child components receive click events
[SWPU2019]Web1
Four-digit display header design
【informix】解决启动报错大全,以及解决办法
Analyses the mainstream across technology solutions
【无标题】
[cesium] element highlighting
human weakness
延迟加载js方式async与defer区别
Day14 jenkins deployment
算法---一和零(Kotlin)
Redis - 13. Development Specifications
Flutter学习5-集成-打包-发布
【转】什么是etcd





![[cesium] element highlighting](/img/99/504ca9802db83eb33bc6d91b34fa84.png)


