1109 Group Photo (25 point(s))

保姆级教程:用+86手机号成功注册Discord的三种亲测方法(附节点选择技巧) 本文提供了三种经过验证的方法,帮助用户使用+86手机号成功注册Discord,包括号码格式调整、网络环境优化和设备组合方案。同时详细解析了'手机号无效'报错的深层原因,并附上节点选择技巧,确保注册流程顺利。 阅读详情

1109 Group Photo (25 point(s))

Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following:

  • The number of people in each row must be N/K (round down to the nearest integer), with all the extra people (if any) standing in the last row;

  • All the people in the rear row must be no shorter than anyone standing in the front rows;

  • In each row, the tallest one stands at the central position (which is defined to be the position (m/2+1), where m is the total number of people in that row, and the division result must be rounded down to the nearest integer);

  • In each row, other people must enter the row in non-increasing order of their heights, alternately taking their positions first to the right and then to the left of the tallest one (For example, given five people with their heights 190, 188, 186, 175, and 170, the final formation would be 175, 188, 190, 186, and 170. Here we assume that you are facing the group so your left-hand side is the right-hand side of the one at the central position.);

  • When there are many people having the same height, they must be ordered in alphabetical (increasing) order of their names, and it is guaranteed that there is no duplication of names.

Now given the information of a group of people, you are supposed to write a program to output their formation.

Input Specification:

Each input file contains one test case. For each test case, the first line contains two positive integers N (≤10​4​​), the total number of people, and K (≤10), the total number of rows. Then N lines follow, each gives the name of a person (no more than 8 English letters without space) and his/her height (an integer in [30, 300]).

Output Specification:

For each case, print the formation -- that is, print the names of people in K lines. The names must be separated by exactly one space, but there must be no extra space at the end of each line. Note: since you are facing the group, people in the rear rows must be printed above the people in the front rows.

Sample Input:

10 3
Tom 188
Mike 170
Eva 168
Tim 160
Joe 190
Ann 168
Bob 175
Nick 186
Amy 160
John 159

Sample Output:

Bob Tom Joe Nick
Ann Mike Eva
Tim Amy John

中档模拟。排序、STL的使用。

注意点:

1. 首先按照身高降序、姓名升序进行排序;

2. 确定每一排的人数(详见代码);

3. 对于每一排的模拟,巧妙使用vector的insert()方法,在vector的头部插入元素;

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
struct person{
	string name;int height;
	bool operator < (const person &other)const{
		if(height!=other.height) return height>other.height;
		return name<other.name;
	}
	person(string n,int h):name(n),height(h){}
};
vector<person> people;
vector<person> row;
vector<person> v;
void sortRow(vector<person> &v){
	row.clear();
	for(int i=0;i<v.size();i++){
		if(i==0) row.push_back(v[i]);
		else{
			if(i%2==1) row.insert(row.begin(),v[i]);
			else row.push_back(v[i]);
		}
	}
	for(int i=0;i<row.size();i++){
		if(i==0) cout<<row[i].name;
		else cout<<" "<<row[i].name;
	}
	cout<<endl;
	v.clear();
}
int main(void){
	int N,K,h;string s;cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>s>>h;
		people.push_back(person(s,h));
	}
	sort(people.begin(),people.end());
	int last = N - (N/K)*(K-1) ;
	v.clear();
	for(int i=0;i<people.size();i++){
		v.push_back(people[i]);
		if(i+1>=last&&(i+1-last)%(N/K)==0){
			sortRow(v);
		} 
	} 
	return 0;
	
}

 

【unity实战】Spline 插件让物体沿路径 “丝滑” 走位,实现火车沿轨道移动——Spline 插件的使用 Unity Spline系统教程:实现火车轨道移动 摘要:本文介绍了Unity Spline系统的核心功能与实战应用,通过火车轨道移动案例演示了完整开发流程。内容包括:1)安装Spline包并绘制样条线轨道;2)调整样条节点和曲线弧度;3)使用Spline Instantiate组件实例化轨道模型;4)通过Spline Animate组件实现小车自动沿轨移动;5)补充讲解了轨道闭合、分支节点、循环模式等进阶技巧。该系统可用于创建河流、摄像机路径等多种曲线应用,文中提供了官方文档链接和详细操作步骤,适合Uni 阅读详情

相关推荐

Vue3+Vite+Electron桌面应用开发:从零到打包的完整避坑指南

本文是一份详尽的Vue3+Vite+Electron桌面应用开发实战指南。文章从项目初始化、环境配置、主进程构建、Vite深度优化,到最终的打包配置与优化,系统性地讲解了使用现代前端技术栈开发跨平台桌面应用的完整流程,并重点分享了开发与打包过程中的常见“坑点”与解决方案,旨在帮助开发者高效构建稳定可交付的桌面端应用。

hh234的博客 109

PAT 甲级 1109 Group Photo

题意:给定一定人名字和高度,给他们拍照,拍照的要求是总共n个人,每排k个人,每排最多站n/k个人,其余站不下的人在较后面一排,每排排序的顺序是最高的站在中间,即m/2放最高人的名字,然后次高的站在左边,在次高的站在右边,即高的先站左边然后在站右边,每个依次进行,每排的高度都是大于前面一排人的高度的。 思路:用一个结构体数组保存每个人的信息,然后从高到低的顺序排序,设置每排人的数量,把最高的姓名放...

qq_42152681的博客 227

【全开源】旅游系统源码(Uniapp+FastAdmin+ThinkPHP)

通过源码的灵活配置和定制开发,我们可以根据旅游企业的实际需求,快速构建出符合其业务特点的旅游系统。旅游系统源码,作为这一变革的基石,为旅游业的数字化转型提供了强有力的支撑。通过深入研究和应用旅游系统源码,我们能够构建出更加智能、便捷、个性化的旅游服务平台,满足游客日益增长的旅游需求。国际化发展:随着全球化的深入发展,旅游系统源码也将迎来国际化的发展机遇,为国内外游客提供更加便捷、高效的旅游服务。跨界融合:旅游系统源码将与更多领域进行跨界融合,如与交通、餐饮、购物等行业的结合,为游客提供更加丰富的旅游体验。

2401_84413757的博客 2154

【PAT】1109 Group Photo (25 分)

1109 Group Photo (25 分) 题目大意:给n个人排成k排,排列规则如下: 每排的人数必须为n/k(向下取整),多余的人排到下一排 后排所有人必须不矮于前排的任何人 每排都将最高的人安排在最中间(最中间为(m/2+1),m为那排的人数,结果要向下取整) 将人们按降序进入一排,然后按左右左右安排位置(For example, given five people with their heights 190, 188, 186, 175, and 170, the final format

SSibyl的博客 307

归因分析计算因子贡献度常见的方法

在归因分析中,我们一般都需要计算出每个因子的贡献度是多少,比如产品DAU上升,对年龄段维度进行拆解,看是不同年龄段的用户对DAU上升的贡献度是多少,一般根据指标的类型,计算贡献度的方法也不一样,下面就列出一些常见的归因分析贡献度的计算方法。

Hubans的博客 4万+

从工创赛实战到开源:一个高鲁棒性智能物流视觉系统的构建与优化

本文分享了从工创赛实战中构建高鲁棒性智能物流视觉系统的完整经验。针对赛场复杂光线环境,详细阐述了摄像头选型、基于CLAHE和形态学梯度的抗干扰色环识别算法、卡尔曼滤波状态估计以及多线程串口通讯与任务调度等核心优化策略,旨在打造一个稳定可靠的视觉系统,并已将相关代码开源。

weixin_29046035的博客 321

1109 Group Photo(25分)

3、每排中高者站中间(中间位置为m/2+1,其中m为该排人数,除法向下取整);每排其他人以 间人为轴,按身高非增序,先右后左交替入队站在中间人的两侧(例如5人身高为190、188、186、 175、170,则队形为175、188、190、186、170。这里假设你面对拍照者,所以你的左边是中间人的右边);若多人身高相同,则按名字的字典序升序排列。先求出每排的人数,然后对整体排序,接着使用双端队列deque分别打印每排的序列。1、每排人数为N/K(向下取整),多出来的人全部站在后一排;

a131529的博客 341

CMake入门教程【基础篇】在Windows、Linux上安装CMake

CMake如何下载与安装

小鱼酱的博客 2727

【坑、逻辑】1109 Group Photo (25 分)

Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra people (if any) standing in the la

weixin_45836276的博客 230

【教程4>第2章>第19节】 GMSK解调系统的FPGA开发与matlab对比验证

MSK(Minimum Shift Keying,最小频移键控)和GMSK(Gaussian Minimum Shift Keying,高斯最小频移键控)都是数字调制技术,主要用于无线通信系统中将数字信号转换为模拟信号进行传输。它们都是连续相位移键控(Continuous Phase Shift Keying, CPK)的一种形式,意味着相邻码元之间没有相位跳变的突变,而是连续过渡,这有助于减少信号带宽和降低邻道干扰。GMSK的解调过程与MSK类似,我们这里还是采用和MSK解调一样的1bit解调方法。

FPGA/MATLAB学习教程/源码/项目合作开发 1221

黑猫带你学eMMC协议第12篇:生产状态感知(PSA)

1 概述 1.1 什么是PSA Production State Awareness (PSA) 生产状态感知 e•MMC设备可以利用其是否在生产环境中的信息,从而在现场运作时进行不同的操作。 例如,在设备低温焊接(soldering)前,将数据写入emmc,可能导致数据出错,而正在焊接期间写入数据,出错的概率可能会更大。在低温焊接之前,emmc设备可以使用一种特定的内部操作去加载内容,这样就能减少数据出错的概率,而在低温焊接后进行常规的操作就行了。 1.2 psa如何进行工作? PSA存在于emmc5.0

黑猫奥利奥的博客 4262

A1109. Group Photo (25| 逻辑题,附详细注释,逻辑分析)

写在前面 实现思路 结构体容器数组封装学生元数据信息 自定义比较函数 容器数组根据身高倒排后,分排 某一排,从原始数组中取第1位放中间 间隔顺序迭代放置左边、右边 具体代码 for(i=t+1; i<t+m; i=i+2) for(i=t+2; i<t+m; i=i+2) 打印输出当前排 注意输出格式,行末不得有多余空格 实现方案有难度,多练习,否则该类题目有...

kngines 477

Android 系统低内存lowmemorykiller关于阈值修改 minfreeAbsKbytes优化

在系统rom定制化开发中,在对于运行内存ram 1G和2G的设备中,对于内存使用高峰期时,minfreeAbsKbytes优化很关键 调整合理的minfree,让内存合理的使用很关键,接下来分析相关功能的实现

安卓兼职framework和app工程师的博客 524

1109 Group Photo (25 point(s))

题解 模拟题。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;string&gt; #include&lt;vector&gt; #include&lt;algorithm&gt; using namespace std; int n, k, m, cnt; struct node { string name; ...

徐伯莱 283

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

1109 Group Photo (25 point(s))

Formation is very important when taking a group photo. Given the rules of formingKrows withNpeople as the following: The number of people in each row must beN/K(round down to the nearest inte...

张蔡辉 197

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

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

PTA甲级 1109 Group Photo (25point(s))

强烈推荐,刷PTA的朋友都认识一下柳神–PTA解法大佬 本文由参考于柳神博客写成 柳神的优快云博客,这个可以搜索文章 柳神的个人博客,这个没有广告,但是不能搜索 还有就是非常非常有用的 算法笔记 全名是 算法笔记 上级训练实战指南 //这本都是PTA的题解 算法笔记 PS 今天也要加油鸭 题目原文 Formation is very important when taking a group photo. Given the rules of forming K rows with N peopl

Huangpengyu123的博客 282

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

PAT(A)1109 Group Photo (25point(s))

Sample Input 10 3 Tom 188 Mike 170 Eva 168 Tim 160 Joe 190 Ann 168 Bob 175 Nick 186 Amy 160 John 159 Sample Output Bob Tom Joe Nick Ann Mike Eva Tim Amy John 思路: 排序求解。 代码 #include<iostream>...

Sqssq的博客 145

1109 Group Photo (25point(s)) - C语言 PAT 甲级

1. 先按照题意排好序 2. printphoto(int m, student *p) 函数利用指针 p 输出每一排的 m 个人

有三只土豆 162

PAT_甲级_1109 Group Photo (25point(s)) (C++)【模拟】

目录 1,题目描述 题目大意 2,思路 数据结构 算法 3,AC代码 4,解题过程 1,题目描述 Sample Input: 10 3 Tom 188 Mike 170 Eva 168 Tim 160 Joe 190 Ann 168 Bob 175 Nick 186 Amy 160 John 159 Sample Output: Bob Tom Joe N...

&再见萤火虫&的博客 180

【PAT】A1109 Group Photo (25)

文章目录1109 Group Photo (25 point(s))Input Specification:Output Specification:Sample Input:Code 1109 Group Photo (25 point(s)) Formation is very important when taking a group photo. Given the rules of fo...

Duke 381

1109 Group Photo(25 分)

Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest inte...

ysq96的博客 975

PAT-A1109/B1055 Group Photo/集体照 题目内容及题解

Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest intege...

BourbonWhiskey 的博客 874

1110 Complete Binary Tree(25 分)

Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) wh...

ysq96的博客 769

1110. Complete Binary Tree (25) 完全二叉树、树的遍历

时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one tes

一叶知秋 2227

1109. Group Photo (25)

1109. Group Photo (25) #include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> using namespace std; struct pers...

areen7003的博客 135

PAT 1109 Group Photo(25 分)

Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest inte...

Hickey_Chen的博客 553
上一篇: 1118 Birds in Forest (25 point(s))
下一篇: 1110 Complete Binary Tree (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值