I - 下沉的船_Java

01 - 什么是SVM 摘要:SVM(共享虚拟内存)技术使CPU和GPU能共享同一虚拟地址空间,简化异构计算编程。传统模型需手动管理CPU/GPU内存和拷贝数据,而SVM允许直接传递指针,自动处理页面迁移和一致性维护。其核心包括统一地址空间、按需迁移、页面故障处理和一致性管理,显著降低编程复杂度并提升性能。通过HMM框架、MMU通知和GPU页面异常等机制实现高效内存共享,支持复杂数据结构,为异构计算带来便利。 阅读详情

Description

一艘船很不幸的撞上了暗礁,船长组织大家上救生艇,而且船长决定女人(woman)和小孩(child)先上船,然后其次是男人(man),最后是船长(captain)。给出原来的顺序,通过编程得到按船长要求排列后的顺序。

身份优先级: woman = child > man > captain.

注意:如果两者的身份优先级一样,请按原来的序列的顺序决定,原序列中在前面的人,依然在前面(具体请看样例)

Input

多组数据(少于10组),每一组有一个整数n(0<n<100),代表船上有n个人,接下来n行,每行有一个名字和他的身份。名字字符长度小于10。数据保证不存在重名,注意可能存在多名船长

Output

输出n行,每一行输出一个名字,先上船的名字在前面。

Sample

Input

6
Jack captain
Alice woman
Charlie man
Teddy woman
Bob child
Julia woman

Output

Alice
Teddy
Bob
Julia
Charlie
Jack

import java.util.*;

class Identity {
	String id,name;

	public Identity(String name, String id) {
		super();
		this.id = id;
		this.name = name;
	}

	//重写输出
	@Override
	public String toString() {
		return name;
	}
	
}

public class Main {
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		//建立不同身份的List
		List<Identity> woman_child = new ArrayList<Identity>();
		List<Identity> man = new ArrayList<Identity>();
		List<Identity> captain = new ArrayList<Identity>();
		
		while(input.hasNext()) {
			//list清空
			woman_child.clear();
			man.clear();
			captain.clear();
			Identity idy;
			int n = input.nextInt();
			
			while(n-->0) {
				//判断身份,加入list
				idy = new Identity(input.next(),input.next());
				if(idy.id.equals("woman") || idy.id.equals("child"))
					woman_child.add(idy);
				else if(idy.id.equals("man"))
					man.add(idy);
				else
					captain.add(idy);
			}
			
			//输出
			for(Identity Idy : woman_child)
				System.out.println(Idy);
			for(Identity Idy : man)
				System.out.println(Idy);
			for(Identity Idy : captain)
				System.out.println(Idy);
		}
		input.close();
	}
}
pscad IEEE标准系统搭建说明 pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。 立即下载

相关推荐

LSCM最小二乘保角参数化

LSCM最小二乘保角参数化 最小二乘思想 已知一组点的数据(x,y) x x1x_1x1​ x2x_2x2​ x3x_3x3​ … xnx_nxn​ y y1y_1y1​ y2y_2y2​ y3y_3y3​ … yny_nyn​ 可以近似为线性关系 y=ax+by=ax+by=ax+b ,目标为确定常数 aaa , bbb ; 解法:找到 aaa , bbb ,使得所有 yiy_iyi​ 与 axi+bax_i+baxi​+b 偏差的平方和 Q=∑i=1n(yi−axi−b)2 Q=\s

weixin_49732532的博客 4254

sdut——下沉的船

题目描述 身份优先级: woman = child > man > captain. 多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名,注意可能存在多名船长 输出  输出n行,每一行输出一个名字,先上船的名字在前面。 示例输入 6 Jack captain Alice wom

清溪浅水 770

FortiClient EMS实战:从安装到配置的全流程优化指南

本文详细解析了FortiClient EMS 7.0版本的部署与优化全流程,帮助企业构建零信任终端安全体系。从环境规划、高效安装、终端纳管到高级运维,提供实战指南和优化技巧,特别适用于Windows Server环境,助力企业提升终端安全管理效率。

weixin_29325007的博客 549

下沉的船

下沉的船 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 身份优先级: woman = child > man > captain. 多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名

略略略的博客 659

vue项目基于WebRTC实现一对一音视频通话

vue项目基于WebRTC实现一对一音视频通话。完整代码gitee地址: https://gitee.com/wade-nian/wdn-webrtc.git。

qq_920189602的博客 6648

Computer Networks 和 Computer & Security投稿经验

论文投稿

qq_50604294的博客 9234

SDUT-2714 下沉的船

Problem Description 一艘船很不幸的撞上了暗礁,船长组织大家上救生艇,而且船长决定女人(woman)和小孩(child)先上船,然后其次是男人(man),最后是船长(captain)。给出原来的顺序,通过编程得到按船长要求排列后的顺序。 身份优先级: woman = child &gt; man &gt; captain. 注意:如果两者的身份优先级一样,请按原来的序列的顺...

qq_43090545的博客 246

VN1630A硬件配置指南:手把手教你用CanApe搭建XCP标定工程(附ELF文件配置技巧)

本文详细介绍了如何使用VN1630A硬件和CanApe软件搭建XCP标定工程,包括硬件配置、CanApe工程创建、ELF文件处理及XCP协议层配置等关键步骤。特别针对实际项目中常见的错误和细节问题提供解决方案,帮助工程师高效完成ECU参数标定工作。

git9versioner的博客 1160

2714 下沉的船

题目描述 身份优先级: woman = child > man > captain. 多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名,注意可能存在多名船长 输出  输出n行,每一行输出一个名字,先上船的名字在前面。 示例输入 6 Jack captain Alice w

顺便A道题 990

AD(Altium Designer)器件封装——立创商城导出原理图和PCB完成器件封装操作指南

官网:www.SZLCSC.COM以芯片为例器件类——>芯片类——>对应芯片确定芯片——>数据手册1:原理图2:PCB3:打开操作流程选中原理图——>文件——>导出——>AD1: ✔2:导出AD文件操作流程选中PCB图——>文件——>导出——>AD1: ✔2:导出AD文件1:PCB图2:原理图操作流程文件——>打开操作流程选中文件——>打开操作流程项目文件——>添加新的...到工程——>Schematic Library新原理图库操作流程项目文件——>添加新的...到工程——>PCB Library新的PC

XU157303764的博客 5437

2025年新发表的语音大模型全双工模型/框架/技术

参考该论文,给出2025年新发表的全双工模型或框架或技术下面这份清单专挑、且与“全双工语音对话/同步对话(边听边说、可打断、回馈/相槌、重叠语音)”直接相关的。我也结合你提到的的四大维度(暂停处理、相槌、顺滑换手、打断管理)来点出它们各自的贡献点,便于后续评测与对比。

u013250861的博客 631

Java-下沉的船

下沉的船Time Limit: 1000 ms Memory Limit: 65536 KiBSubmit StatisticProblem Description身份优先级: woman = child &gt; man &gt; captain.多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名,注意可能存在多名船长...

Just like myself. 246

不会路由器叠加多条宽带?看这个就够了,能让你的局域网速度更快!

通常我们在企业网络或实际项目中,随着用户的增加,一条或者几条带宽不能满足正常使用,便可以对带宽进行叠加,便于网络带度更快;通常家里有可能有两条带宽的,联通或移动的,可能都是充话费送的,但网速都不怎么样,不用可惜,用之委屈,那怎么办呢?如在迅雷上开启下载,多个资源同时下载,此时总带宽可以达到120M,也就是WAN口带宽可以叠加。多wan口路由器, 一般是有2个wan口,分别为wan1与wan2。当然也有更多的wan口的。[1] 对整个局域网来说,出口带宽数量多了,相当于总带宽上升,这样是可以起到叠加效果。

qq_43416206的博客 1112

sdut_java_下沉的船

下沉的船 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 身份优先级: woman = child > man > captain. 多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名

meng_qingxia的博客 427

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

深度学习工具包 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")

2714-下沉的船

下沉的船Time Limit: 1000 ms Memory Limit: 65536 KiBSubmit StatisticProblem Description身份优先级: woman = child &gt; man &gt; captain.多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名,注意可能存在多名船长...

w_j_r的博客 260

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

下沉的船_JAVA

Description 一艘船很不幸的撞上了暗礁,船长组织大家上救生艇,而且船长决定女人(woman)和小孩(child)先上船,然后其次是男人(man),最后是船长(captain)。给出原来的顺序,通过编程得到按船长要求排列后的顺序。 身份优先级: woman = child > man > captain. 注意:如果两者的身份优先级一样,请按原来的序列的顺序决定,原序列中在前面的人,依然在前面(具体请看样例) Input 多组数据(少于10组),每一组有一个整数n(0<n<1

baiqiaoxiang的博客 169

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

下沉的船 优快云-Rwen

下沉的船 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 一艘船很不幸的撞上了暗礁,船长组织大家上救生艇,而且船长决定女人(woman)和小孩(child)先上船,然后其次是男人(man),最后是船长(captain)。给出原来的顺序,通过编程得到按船长要求排列后的顺序。 身份优先级: woman = child ...

rwlvjj的博客 220

Java sdut acm 2714 下沉的船(字符串、链表)

题目链接:点击打开链接 下沉的船 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 身份优先级: woman = child > man > captain. 多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名

Annfan123的博客 622

SDUT-oj 下沉的船

下沉的船 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 身份优先级: woman = child > man > captain. 多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名

努力努力再努力 606

SDUTOJ 2714 - 下沉的船

Problem Description 一艘船很不幸的撞上了暗礁,船长组织大家上救生艇,而且船长决定女人(woman)和小孩(child)先上船,然后其次是男人(man),最后是船长(captain)。给出原来的顺序,通过编程得到按船长要求排列后的顺序。 身份优先级: woman = child > man > captain. 注意:如果两者的身份优先级一样,请按原来的序列的顺序决定...

sugerandmaster 136

Java下沉的船

下沉的船 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 身份优先级: woman = child &gt; man &gt; captain. 多组数据(少于组),每一组有一个整数(,代表船上有个人,接下来行,每行有一个名字和他的身份。名字字符长度小于。数据保证不存在重名,注意可...

曌的博客 433
上一篇: L - 学生信息的添加与查询_Java
下一篇: J - 分类游戏_Java
笑着找bug
博客等级 码龄7年 22粉丝 135原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值