【PAT】1114. Family Property (25)

11、ThingsBoard集群部署k8s 今天终于有时间去搞这个啦,拖了很久了,一直没时间,因为我本地没有那么多机器资源,开虚拟机不够,如果租用阿里云服务器,需要有充值的时间,因为这个费用是按小时付费,需要有连贯的时间来搞才行,今天恰好有时间,就开始搞了,弄成功搞出来了,特地写博客记录下来。 阅读详情

1114. Family Property (25)

This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each family, and the average area and number of sets of their real estate.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (<=1000). Then N lines follow, each gives the infomation of a person who owns estate in the format:

ID Father Mother k Child1 ... Childk M_estate Area

where ID is a unique 4-digit identification number for each person; Father and Mother are the ID's of this person's parents (if a parent has passed away, -1 will be given instead); k (0<=k<=5) is the number of children of this person; Childi's are the ID's of his/her children; M_estate is the total number of sets of the real estate under his/her name; and Area is the total area of his/her estate.

Output Specification:

For each case, first print in a line the number of families (all the people that are related directly or indirectly are considered in the same family). Then output the family info in the format:

ID M AVG_sets AVG_area

where ID is the smallest ID in the family; M is the total number of family members; AVG_sets is the average number of sets of their real estate; and AVG_area is the average area. The average numbers must be accurate up to 3 decimal places. The families must be given in descending order of their average areas, and in ascending order of the ID's if there is a tie.

Sample Input:
10
6666 5551 5552 1 7777 1 100
1234 5678 9012 1 0002 2 300
8888 -1 -1 0 1 1000
2468 0001 0004 1 2222 1 500
7777 6666 -1 0 2 300
3721 -1 -1 1 2333 2 150
9012 -1 -1 3 1236 1235 1234 1 100
1235 5678 9012 0 1 50
2222 1236 2468 2 6661 6662 1 300
2333 -1 3721 3 6661 6662 6663 1 100
Sample Output:
3
8888 1 1.000 1000.000
0001 15 0.600 100.000
5551 4 0.750 100.000
分析:用图(并查集)结构存储输入;用bfs遍历计算。

细节:图的边为无向边;

(以下代码比较丑,还是完整定义图结构比较迅速方便)


#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <vector>
#include <functional>

#define rep(i,j,k) for(int i=j;i<=k;++i)
const int Max=10000;
using namespace std;

class node
{
	public:
		int id;
		int sets;
		int area;
		vector<int> family;
		node(){
			id=sets=area=0;
		};
};

struct res
{
	int minres;
	float set,are;
	int sum;
	friend bool operator < (const res& a, const res& b){
		return a.are<b.are || (a.are==b.are && a.minres>b.minres);
	}
};

vector<int> root;
node estate[Max];
int visited[Max];
priority_queue<res> result;

void create(int n)
{
	while (n--){
		node x;
		int id,f,m,k;
		scanf("%d %d %d %d",&id, &f, &m, &k);
		root.push_back(id);
		x.id=id;
		x.family.push_back(f);
		x.family.push_back(m);
		estate[f].family.push_back(id); // f==-1时仍然可以执行 
		estate[m].family.push_back(id); //
		while (k--){
			int c;
			scanf("%d",&c);
			x.family.push_back(c);
			estate[c].family.push_back(id);
		}
		int s,a;
		scanf("%d %d",&s, &a);
		x.sets=s;
		x.area=a;
		estate[id]=x;
	}
}

void bfs(int root)
{
	queue<int> q;
	int minres=10000;
	int sum=0;
	float set=0,are=0;
	q.push(root);
	visited[root]=1;
	int v;
	while(!q.empty()){
		v=q.front();
		if (v<minres) minres=v;
		++sum;
		set+=estate[v].sets;
		are+=estate[v].area;
		int size=estate[v].family.size();
		rep(i,0,size-1){
			if (estate[v].family[i]==-1) continue; 
			if (visited[estate[v].family[i]]!=1){
				visited[estate[v].family[i]]=1;
				q.push(estate[v].family[i]);
			}
		}
		q.pop();
	}
	res t;
	t.minres=minres;
	t.set=set/sum;
	t.are=are/sum;
	t.sum=sum;
	result.push(t);
}

void major()
{
	
	rep(i,1,root.size()){
		if (visited[root[i-1]]!=1){
			bfs(root[i-1]);
		}
	}
	cout<<result.size()<<endl;
	while (!result.empty()){
		res t=result.top();
		printf("%04d %d %.3f %.3f\n", t.minres, t.sum, t.set, t.are);
		result.pop();
	}
}


int main()
{
//	freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	create(n);
	major(); 
	return 0;
}



R语言 Chow Test Chow 测试用于测试不同数据集上的两个不同回归模型中的系数是否相等。 该测试通常用于计量经济学领域,使用时间序列数据来确定数据在某个时间点是否存在结构性中断。 本教程提供了如何在 R 中执行 Chow 测试的分步示例 首先,我们将创建一些假数据: #create data data <- data.frame(x = c(1, 1, 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 阅读详情

相关推荐

Polardb训练营-本地部署 PolarDB-X

PolarDB-X是阿里巴巴自主设计研发的高性能云原生分布式数据库产品,为用户提供高吞吐、大存储、低延时、易扩展和超高可用的云时代数据库服务。云原生+MySQL生态PolarDB-X已作为标准云产品在世界范围内的13个地区提供服务。依托云资源和容器化部署能力,PolarDB-X可以在数分钟内完成集群创建和变配,整个过程中用...

yangjunfeng0604的博客 2472

PAT A1114

难度不大,就是过于繁琐 #include<iostream> #include<set> #include<vector> #include<algorithm> using namespace std; const int maxn = 10000; int n, father[maxn]; struct node{ double mest, area; }Node[maxn]; struct family{ int id, m; double .

学习笔记,不喜勿喷! 134

小蔺的米哈游数据分析师之路——MYSQL篇

作为新人,记录自己mysql学习历程

weixin_47070228的博客 434

pat a 1114

#include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <unordered_set> using namespace std; const int maxv=10010; int father[maxv]; bool v...

blxl313的博客 170

MacOS上如何修改jupyter book的默认打开地址以及如何复制文件路径

记点笔记,才换新系统小半年,还是不太熟悉,所以记录一下笔记,感觉之后也会用到,希望能帮到你们。主要内容是:修改jupyter的默认地址以及复制文件路径。

魔仙的博客 1978

Cadence 17.2 OrCAD原理图库实战:从零创建电阻/电容/LED元件(附封装技巧)

本文以Cadence 17.2 OrCAD为核心,详细讲解了如何从零开始工程化地创建电阻、电容、LED等原理图库元件。内容涵盖库架构设计、符号绘制、引脚属性管理、封装关联技巧以及设计规则检查,旨在帮助硬件工程师构建规范、可复用且易于维护的元件库,为高效PCB设计奠定坚实基础。

weixin_29195615的博客 400

PAT——1114 全素日

以上图片来自新浪微博,展示了一个非常酷的“全素日”:2019年5月23日。即不仅20190523本身是个素数,它的任何以末尾数字3结尾的子串都是素数。本题就请你写个程序判断一个给定日期是否是“全素日”。

Jamaple的博客 760

python中有趣的库 freegames 的详细使用

freegames 是一个包含多个简单 Python 游戏的开源库,适合初学者学习 Python 编程和游戏开发。以下是 freegames 的详细介绍和用法示例。

数据知道的博客 3万+

pat A1114

网上找了一篇博客,链接给出https://blog.csdn.net/jolivan/article/details/59481949 但它存在一个问题:拥有共同孩子的两个人没有归到同一个家庭 自己动手修改后: //pat A1114 Family Property(25 分) #include &lt;cstdio&gt; #include &lt;algorithm&gt; #incl...

qq_38705851的博客 418

第三方 API 调用 OpenClaw 出现 LLM request timed out 的解决方案

本文主要介绍了第三方 API 调用 OpenClaw 出现 LLM request timed out 的解决方案,希望能对使用OpenClaw的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 8万+

使用 MATLAB/Simulink 构建一个 基于神经网络控制的单相并网逆变器系统

单相并网逆变器广泛应用于户用光伏小型储能和电动汽车V2G等场景。其核心控制目标是实现高质量的并网电流,即电流与电网电压同频同相(单位功率因数),且总谐波畸变率 (THD)极低。非线性因素:电力电子器件的开关死区非线性电感寄生参数。参数不确定性:滤波器元件(L, C)的老化温漂。电网扰动:电压谐波频率波动不平衡。模型依赖性:PI、PR等控制依赖于精确的系统模型,模型失配导致性能下降。动态响应:在光照突变(光伏)或负载突变(储能)下,需快速、无超调地响应。

xiaoheshang_123的博客 274

PAT【甲级】1114

题目链接:PAT【甲级】1114 题目简述:给定每个⼈人的家庭成员和其⾃自⼰己名下的房产,要求统计出每个家庭的⼈人⼝口数、⼈人均房产⾯积及房产套数。家庭信息⾸先按⼈均⾯积降序输出,若有并列,则按成员编号的升序输出。 #include<bits/stdc++.h> using namespace std; unordered_map<int, int> areas, sets, members; int father[10000], exist[10000], minID[10000

qq_41375322的博客 230

扣子(Coze)搭建智能体完整实战指南 —— 从零基础入门到写小说及其他需求扩展开发

随着大语言模型进入应用爆发期,我们正在经历从“寻找提示词”向“构建智能体”的范式转移。扣子(Coze)作为字节跳动推出的一站式AI智能体开发与运营平台,极大地降低了AI应用开发的门槛,让非技术人员也能快速搭建具备感知、决策、行动能力的智能体。 本文将手把手带你从零开始,在扣子平台上搭建一个功能完备的**小说创作智能体**,并基于此展示如何将同一套架构扩展到其他需求场景。无论你是写作爱好者、内容创作者,还是希望用AI赋能日常工作的职场人士,这套完整的技术方案都将帮助你快速上手。

huanghm88的专栏 638

PAT甲级——A1114 Family Property【25】

This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of e...

weixin_30632089的博客 149

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

PAT甲级题解A1114 Family Property (25分)

PAT甲级题解 A1114 Family Property (25分) #include<iostream> #include<vector> #include<map> #include<algorithm> #include<cmath> using namespace std; const int eps = 1e-7;//double类型比较,这题貌似不用。 const int MAXN = 10010; int fa[MAXN], set

cold_lemon的博客 237

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

PAT A1114. Family Property (25)

Family Property (25) 时间限制 150 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This time, you are supposed to help us collect the data for family-owned property. Given each pers...

jackiewoo_的博客 214

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

PAT甲级A1114 Family Property (25 分)

This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each f...

vir_lee的博客 301

pat 1114. Family Property (25)

https://www.patest.cn/contests/pat-a-practise/1114#include #include #include #include #include #include #include #include #include using namespace std; typedef struct family { int minId; in

guojiaqi007的专栏 344

PAT-甲级-1114 Family Property (25 分)

1114Family Property(25分) This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we ne...

valcanoshan的博客 163

PAT甲级1114 Family Property (25 分)

1114Family Property(25分) This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we ne...

Dexter 166

PAT A1114 Family Property (25 分) 并查集

题目大意:给出N个人的信息,信息中包括他的父母和子女的id(4位数),以及他名下的房产数量和面积。求出一共有多少个家庭,以及每个家庭的平均房产数和平均房产面积,并输出这个家庭中id最小的成员。 并查集问题,一开始看到 N<=1000,id是四位数,考虑能不能通过对应来缩小范围,但是这是不可以的,因为包括他的父母和子女在内,远超过N个人。所以还是只能从0遍历到9999, 输入...

HackingGate的博客 200

1114. Family Property (25)(PAT 并查集)

题目地址https://www.patest.cn/contests/pat-a-practise/1114ac注意 主要是并查集,不能漏掉 int fa[N];int find(int x) { if(x == fa[x]) return x; return fa[x] = find(fa[x]); }void merg(int x, int y) { int xx = fin

master-dragon的专栏 970

PAT A 1114 Family Property (25分)

一、题目概述 依据给定个人房产信息、家族信息,统计: 1、家族数量(有任一种血缘关系即属于同一家族); 2、各家族的:家族代表(全家最小ID)、家族成员数、家族平均房产数、家族平均房产面积。 二、思路 无向图dfs统计。 set作为数据结构存储所有id,实现id升序遍历,则家族遍历起点即家族代表id(最小号id)。 三、代码 #include <cstdio> #include &lt...

Siumai's Blog 213

PAT 甲级 1114 Family Property (25 分)

思路: 1.用结构体将每一个人的信息存储下来,同时将每一个人的家人也作为一个人存储下来,为了使用这些人的家人部分; 2.设立map标记某一个人是否被遍历过、是否在输入给定的人里(每行输入的第一个id)(为了确定遍历到这个人时要不要加上他的资产); 3.将人以id为key存入map,从头开始遍历,可以解决家族中输出id最小的问题; 4.设立家族结构体,储存相应变量,并编写相应排序规则,每遍历完一个家...

Yuhan的博客 182

【PAT】A1114 Family Property (25 point(s))

文章目录A1114 Family Property (25 point(s))Input Specification:Output Specification:Sample Input:Sample Output: A1114 Family Property (25 point(s)) This time, you are supposed to help us collect the data ...

Duke 253

[PYTHON](PAT)1114 FAMILY PROPERTY(25 分)

This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each f...

贰拾壹 219
上一篇: 【PAT】1102. Invert a Binary Tree (25)
下一篇: 【PAT】1007. Maximum Subsequence Sum (25)
浆糊串磕楠
博客等级 码龄10年 4粉丝 49原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值