PAT甲级1034

Unlocking Decoding-time Controllability: Gradient-FreeMulti-Objective Alignment with Contrastive Pr 将基于庞大网络语料库训练的大型语言模型(LLMs)(OpenAI,2023;Touvron 等,2023;Google,2023)与人类偏好对齐,是减少产生不安全(Wei 等,2023)、幻觉(Zhang 等,2023b)和有偏见(Gallegos 等,2023)内容的重要一步。随着偏好学习技术(如 PPO(Schulman 等,2017)、DPO(Rafailov 等,2023)及其他变体(Azar 等,2023;Ethayarajh 等,2024; 阅读详情

PAT甲级1034

题目:
One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls made between the two persons. A “Gang” is a cluster of more than 2 persons who are related to each other with total relation weight being greater than a given threshold K. In each gang, the one with maximum total weight is the head. Now given a list of phone calls, you are supposed to find the gangs and the heads.

Input Specification:
Each input file contains one test case. For each case, the first line contains two positive numbers N and K (both less than or equal to 1000), the number of phone calls and the weight threthold, respectively. Then N lines follow, each in the following format:

Name1 Name2 Time
where Name1 and Name2 are the names of people at the two ends of the call, and Time is the length of the call. A name is a string of three capital letters chosen from A-Z. A time length is a positive integer which is no more than 1000 minutes.

Output Specification:
For each test case, first print in a line the total number of gangs. Then for each gang, print in a line the name of the head and the total number of the members. It is guaranteed that the head is unique for each gang. The output must be sorted according to the alphabetical order of the names of the heads.

Sample Input 1:
8 59
AAA BBB 10
BBB AAA 20
AAA CCC 40
DDD EEE 5
EEE DDD 70
FFF GGG 30
GGG HHH 20
HHH FFF 10
Sample Output 1:
2
AAA 3
GGG 3
Sample Input 2:
8 70
AAA BBB 10
BBB AAA 20
AAA CCC 40
DDD EEE 5
EEE DDD 70
FFF GGG 30
GGG HHH 20
HHH FFF 10
Sample Output 2:
0

题目大意:给出n行电话记录,只要A打过电话给B或者B打过电话给A,这两个人就算一个圈子里,若一个圈子里的人电话记录里的总时间超过k并且人数不少于3个则属于一个犯罪团伙,找出总共几个团体,并且输出团队首领(通话总时长最多的那个)
这题属于图的遍历,查找连通图的个数,邻接表邻接图都可,柳神用的图,所以自己手写了个表的遍历。团队数组最高不会超过334,按字典序从小到大排,主要都在DFS里,设置visit数组,访问过则设为true,这里要注意DFS遍历时候无论有没有访问过都要置为true且不能提前跳出,因为要有个全局变量记录总电话时长以便比较是否符合犯罪团伙要求,如果提前跳出一定会有边少算。还有就是字符串转int用map即可,最大数组容量不能小于2000

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#define MAXN 2002
using namespace std;

struct gang{
	string head;
	int number=0;
}g[340];
bool cmp(gang a,gang b){
	return a.head<b.head;
}
struct node{
	int next;
	int length;
	node(int _next,int _length){
		next=_next,length=_length;
	}
};
vector<node> adjv[MAXN];
int length[MAXN];
bool visit[MAXN]={false};
map<string,int> stringtoint;
map<int,string> inttostring;
int totalmember,totaltime,maxtime;
string head;
void DFS(int k){
	visit[k]=true;	//无论有没有访问过都要设为true
	if(0==adjv[k].size()) return ;	//若k节点没有边了则返回
	for(int i=0;i<adjv[k].size();i++){
		if(!visit[adjv[k][i].next]){	//k的第i条边未访问
			visit[adjv[k][i].next]=true;
			totalmember++;	//第一次碰到总人数加1
			if(length[adjv[k][i].next]>maxtime){	//确定是否是头目
				maxtime=length[adjv[k][i].next];
				head=inttostring[adjv[k][i].next];
			}
			DFS(adjv[k][i].next);	//继续往下查找
		}
		totaltime+=adjv[k][i].length;	//这里总时间打电话和接电话都要算
	}
	return ;
}
int main(){
	int n,k,tmp,cnt=0,total=1;
	string name1,name2;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		cin>>name1>>name2;
		scanf("%d",&tmp);
		if(stringtoint[name1]==0){
			stringtoint[name1]=total;
			inttostring[total]=name1;
			total++;
		}
		if(stringtoint[name2]==0){
			stringtoint[name2]=total;
			inttostring[total]=name2;
			total++;
		}
		adjv[stringtoint[name1]].push_back(node(stringtoint[name2],tmp));
		length[stringtoint[name1]]+=tmp;
		length[stringtoint[name2]]+=tmp;
	}
	for(int i=0;i<MAXN;i++){
		if(adjv[i].size()!=0){
			if(!visit[i]){
				totalmember=1,totaltime=0;
				maxtime=length[i],head=inttostring[i];
				DFS(i);
				if(totalmember>2&&totaltime>k){
					g[cnt].head=head;
					g[cnt].number=totalmember;
					cnt++;
				}
			}
		}
	}
	sort(g,g+cnt,cmp);
	printf("%d\n",cnt);
	for(int i=0;i<cnt;i++){
		cout<<g[i].head<<" "<<g[i].number<<endl;
	}
	system("pause");
	return 0;
}
AUTOSAR EcuM模块介绍 AUTOSAR EcuM概述 AUTOSAR EcuM全称是Autosar ECU State Manager,位于Autosar BSW中System Service模块中,是一个独立于硬件的模块。 其主要作用是管理ECU上下电启动的状态,具体为: 初始化启动操作系统所需要的BSW(Basic Software)模块 为睡眠阶段和随后的唤醒完成微控制器的配置准备 管理ECU上的所有唤醒事件(EcuM通过唤醒验证协议验证已发生的唤醒,区分真实的唤醒事件,防止误唤醒) EcuM支持的特性列表 EcuM具有 阅读详情

相关推荐

AI风控系统中的实时决策架构:架构师的关键设计

当用户点击「确认支付」时,一场毫秒级的“欺诈攻防战”正在后台悄然打响:系统需要在100ms内完成用户行为特征提取→欺诈模型推理→规则引擎校验→最终决策返回。这就是AI风控实时决策架构的核心——用技术对抗“实时化的欺诈手段”。本文将以「餐厅智能点餐系统」为类比,拆解实时风控架构的每一层逻辑:从“如何快速拿到用户的实时行为特征”(像服务员实时收集顾客的忌口),到“如何让模型和规则协同决策”(像厨师长结合菜谱和经验判断菜能不能做),再到“如何保证系统扛住大促的高并发”(像餐厅加桌子应对客流高峰)。我们会用。

2502_91592937的博客 1472

【PAT甲级】1034 Head of a Gang (30 分)

PAT甲级1034题解

小染的学习笔记 927

中国区ASP服务性规范考试

10、每次现场维护服务,工程师需按照400要求达到现场的时间与客户联系,在抵达现场、故障恢复后两个时间点分别向400报CALL ,如与客户联系变更到现场时间点,也需向400电话备案(400-822-9999)……20、工程师小B 在接到客户故障申报后赶到客户现场,发现问题无法解决,于是及时将情况反馈至技术支持响应工程师小C ,小B 就和小C 协商由小C 远程解决此问题,后小B 离开客户现场。18、小L 到客户现场交付安装服务。6、EPMS 中上载初验证书的命名规则为:合同号+初验的客户签署日期……

2301_76197693的博客 1907

1034 Head of a Gang (30 point(s))

1034 Head of a Gang (30 point(s)) One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length o

佳迪斯的博客 188

RV1126上YOLOv8部署实战:从模型转换到板端推理的完整避坑指南

本文提供了在瑞芯微RV1126芯片上部署YOLOv8目标识别算法的完整实战指南。内容涵盖从模型转换、环境搭建到板端推理代码编写的全流程,重点解析了RKNN-Toolkit使用、量化配置、内存优化及后处理实现等关键环节的常见问题与解决方案,旨在帮助开发者高效避坑,实现边缘AI应用的稳定落地。

pz89012345的博客 568

关于42步进电机驱动——基于STM32 HAL库实现

我找了好多资料,好多关于42步进电机的都是文档,这么文档都需要积分,需要积分就算了内容还非常差,浪费时间和电脑的内存。关于大部分是基于Arduino和51去驱动的 42步进电机驱动硬件如下: 首先你要了解步进电机的驱动原理,我也不啰嗦了,请看这边博客: 二相四线,四相五线,四相六线步进电机接线及驱动方法 , 看完这篇你就知道驱动和接线的原理了。 起初我也为如何接线烦恼,因为有些博客在讲述这些问题的时候没有讲的很透彻。 方法如下: ①用万用表调到欧姆档,用其中一个表笔搭在一个引脚上,依次测其它.

Jodan132的博客 1万+

Head of a Gang(并查集,多连通图)

题目描述One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to ...

qq_31342997的博客 407

使用MATLAB/Simulink对一个简单的智能家居温湿度监测与控制系统进行建模和仿真

目录手把手教你学Simulink——基于Simulink的智能家居温湿度监测与控制仿真建模示例一、背景介绍二、所需工具和环境三、步骤详解步骤1:创建Simulink模型步骤2:构建传感器模块步骤3:添加控制器步骤4:构建执行器模块步骤5:连接各部分步骤6:设置仿真参数步骤7:添加观测器步骤8:运行仿真并分析结果四、总结 智能家居系统中的温湿度监测与控制系统是一个典型的物联网(IoT)应用场景,它通过传感器收集环境数据,并根据预设条件自动调节室内温度和湿度以提高居住舒适度。本指南将介绍如何使用MATLAB/S

xiaoheshang_123的博客 291

PAT甲级1034 Head of a Gang//DFS运用

One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls made between

冷眼看world的博客 228

基于STM32设计的智能家居系统(采用ESP8266+OneNet云平台)

一、环境介绍 单片机采用:STM32F103C8T6 上网方式:采用ESP8266,也可以使用其他设备代替,只要支持TCP协议即可。比如:GSM模块、有线网卡等。 云平台: 采用中国移动OneNet. 也可以采用腾讯、阿里云、华为云、百度天工物接入、机智云等等。 前面文章有讲解。 协议: 采用MQTT协议 开发软件:keil5 完整项目源码下载:https://download.youkuaiyun.com/download/xiaolong1126626497/19766925 二、包含的硬件与实...

1万+

PyTorch生成式人工智能(25)——基于Transformer实现机器翻译

不同于循环神经网络 (RNN) 按顺序处理数据,Transformer 以并行的方式处理输入数据(例如句子)。这种并行处理提高了效率,但并未使其能够识别输入的顺序。为了解决这个问题,Transformer 向输入的词嵌入中添加了位置编码。这些位置编码是分配给输入序列中每个位置的独特向量,其维度与输入词嵌入对齐。本节将以英语到法语的翻译为例,通过介绍如何训练 Transformer 模型将英语句子转换为法语,深入理解 Transformer 的架构及自注意力机制的运作方式。

盼小辉丶的博客 2727

【PAT(甲级)】1034 Head of a Gang

解题思路: 就是一个并查集,加一个权重判断的问题。可以用bfs来遍历所有节点,然后找到权重最大的节点就是帮派的头目。其中的难点就在于,节点不是常规的数字,而是string类型的名字。我的解决方法就是直接用map给他们匹配一下。...

weixin_55202895的博客 262

ROS局部路径规划器插件teb_local_planner流程梳理(上)

在我之前的文章《ROS导航包Navigation中的 Movebase节点路径规划相关流程梳理》中已经介绍过Move_base节点调用局部路径规划器插件的接口函数是computeVelocityCommands,接下来,我们就从这个函数入手梳理一下teb_local_planner功能包的工作流程。

慕羽★的博客 5165

PAT甲级 A1034

PAT甲级 A1034 题目详情 1034 Head of a Gang (30分) One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time

weixin_44065549的博客 406

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

pat甲级1034(30分)c++

pat甲级1034(30分)c++ 类型:图的遍历(dfs) #include <iostream> #include <map> using namespace std; /* * 题目大意: * 输入: * 第一行: * N是通话次数,K是权重阈值 * 接下来N行: * 每一行: * 两个string和一个边权 * 输出: * 第一行: * 符合连通...

幽冥狐尊的博客 208

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

PAT甲级1034Head of Gang

/记录群组号和累计通话时间。对此题写了一个递归式的gangs划分,同一个gangs传播式扩张;//先给每个人分配一个群组。//根据信息来融合群组。//以群组号分开记录。

2401_87267766的博客 1428

【PAT甲级题解记录】1034 Head of a Gang (30 分)

Problem:1034 Head of a Gang (30 分)Tags:图的遍历 连通分量统计 DFS。

retr0的博客 458

题178.pat甲级练习-1034 Head of a Gang (30 分)

文章目录题178.pat甲级练习-1034 Head of a Gang (30 分)一、题目二、题解 题178.pat甲级练习-1034 Head of a Gang (30 分) 一、题目 二、题解 本题要你找出总通话时间大于K,并且圈子人数大于2人的圈子,输出每个符合条件的圈子中通话时间最长的人以及圈子的人数,并注意输出顺序按名字字典序。本质就是个并查集问题,难度不大,就是想的时候感觉要照顾的信息有点多,又要并查得到圈子人数以及圈子的总通话时间又要知道每个圈子里的人这样才方便找圈子中最长

Adongua的博客 425

pat甲级1034 图的深度优先遍历

以为名字只能是三个一样的字母,这样最多26个人,实际上最多有2000人,思路是对的 #include <cstdio> #include <vector> #include <algorithm> using namespace std; struct gang{ int head, people; }; const int maxv = 26; ...

sinat_37517996的博客 217

PAT甲级1034 并查集

分数 30。

qq_62368250的博客 1501

PAT 甲级 1034 JAVA

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static Map<String, Person> map_person_time = new HashMap<>(); static List<Set<String>> clu

Zaaztt的博客 151

1034 Head of a Gang带权并查集

1034 Head of a Gang PAT甲级带权并查集 题目传送门 并查集基础(通俗易懂) 原文链接 先扯一下,本人的第一篇博客,写的不好有错误请dalao指出,有问题可以一起讨论。这题并不是特别难,但我第一次写完完整的带权并查集,纪念一下。并查集还是挺基础的,主要就是init()、find(x)、join(x,y)三个函数,推荐看下链接,通俗易懂。当初大一上不是很理解,现在觉得当初好蠢。 思路: 就是tim记录每个人的通话时间,然后用并查集合并团伙,当一个团伙人数大于2并且总通话时间大于k

weixin_46173995的博客 923

PAT 甲级 1034 PAT Ranking 个人错误总结

有点难,编码复杂。 dfs需要找到,每个连通图数值总数,最大值结点,结点个数,还要用hash来修正字母,最后还要sort。 很容易写错,一开始我想的是用并查集,特别麻烦,因为没法保证根节点就是最大点,也没法记录总数,只能在最后用map遍历。 #include<bits/stdc++.h> using namespace std; vector<int> llist[30000]; int v[30000]; struct node{ string a; int n; }; int

☁的博客 166

PAT甲级 1034(C++)

代码参考:1034. Head of a Gang (30)-PAT甲级真题(图的遍历dfs)_柳婼 の blog-优快云博客

weixin_45681165的博客 217
上一篇: PAT甲级1098
下一篇: PAT甲级1013
zerohawk
博客等级 码龄8年 3粉丝 78原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值