简单模拟。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std; struct X
{
string name;
int h;
} s[+];
int n,k;
vector<int>g[];
int tmp[+]; bool cmp(const X&a,const X&b)
{
if(a.h==b.h) return a.name<b.name;
return a.h>b.h;
} int main()
{
scanf("%d%d",&n,&k);
for(int i=; i<=n; i++)
cin>>s[i].name>>s[i].h;
sort(s+,s+n+,cmp); int t=n+;
for(int i=k; i>=; i--)
{
int m;
if(i>) m=n/k;
else m=n-n/k*(k-);
t=t-m;
int y=t,p=m/+,sz=;
int L,R;
tmp[p]=y++,sz++,L=p-,R=p+;
while()
{
if(sz==m) break;
if(sz%==) tmp[R++]=y++;
else tmp[L--]=y++;
sz++;
}
for(int j=;j<=m;j++) g[i].push_back(tmp[j]); }
for(int i=; i<=k; i++)
{
for(int j=; j<g[i].size(); j++)
{
cout<<s[g[i][j]].name;
if(j<g[i].size()-) printf(" ");
else printf("\n");
}
}
return ;
}

PAT (Advanced Level) 1109. Group Photo (25)的更多相关文章

  1. 【PAT甲级】1109 Group Photo (25分)(模拟)

    题意: 输入两个整数N和K(N<=1e4,K<=10),分别表示人数和行数,接着输入N行每行包括学生的姓名(八位无空格字母且唯一)和身高([30,300]的整数).按照身高逆序,姓名字典序 ...

  2. 1109 Group Photo (25分)

    Formation is very important when taking a group photo. Given the rules of forming K rows with N peop ...

  3. 1109. Group Photo (25)

    Formation is very important when taking a group photo. Given the rules of forming K rows with N peop ...

  4. PAT甲题题解-1109. Group Photo (25)-(模拟拍照排队)

    题意:n个人,要拍成k行排队,每行 n/k人,多余的都在最后一排. 从第一排到最后一排个子是逐渐增高的,即后一排最低的个子要>=前一排的所有人 每排排列规则如下: 1.中间m/2+1为该排最高: ...

  5. PAT (Advanced Level) 1114. Family Property (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  6. PAT (Advanced Level) 1105. Spiral Matrix (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...

  7. PAT (Advanced Level) 1101. Quick Sort (25)

    树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...

  8. PAT (Advanced Level) 1071. Speech Patterns (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  9. PAT (Advanced Level) 1063. Set Similarity (25)

    读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...

随机推荐

  1. 网页 JavaScript的DOM操作

    今天,我首先对之前学习的内容进行了复习,然后学习了当鼠标指向某一个按钮时,切换对应的背景图片. <div id="d1"> </div> <input ...

  2. iOS9如何隐藏各种bar

    转载自:http://www.cnblogs.com/aBigRoybot/articles/2234487.html 状态条StatusBar 1 [UIApplication sharedAppl ...

  3. MAC图片格式转换

    OS X下有一个sips的程序可以用来处理图片. sips的名称功能非常强大,参考 帮助文档 . 这里我们只用到其中的一个功能,转换图片格式. 命令参考: sips  - s format jpeg  ...

  4. PMP培训感想

      终于等到了C打头的邮件,等了几个星期,悬着的心终于放了.1P4M,基本跟平时模块成绩一致.当初模考时,第一次考了126,还算比较满意,毕竟还没开始苦逼看嘛,悲剧的是不管后面再怎么努力,成绩始终在1 ...

  5. 关于LR监视Windows和linux的说明

    一.监控windows系统: 1.监视连接前的准备工作 1)进入被监视windows系统,开启以下二个服务Remote Procedure Call(RPC) 和Remote Registry Ser ...

  6. Chapter 2 Open Book——3

    But when I walked into the cafeteria with Jessica — 但是当我和Jessica 一起走进自助餐厅的时候 trying to keep my eyes ...

  7. SELECT TOP 1 * FROM是什么意思

    SELECT TOP 1 * FROM的含义: 1.select为命令动词,含义为执行数据查询操作: 2.top 1子句含义为查询结果只显示首条记录: 3.*子句表示查询结果包括数据源中的所有字段: ...

  8. Oracle小技术集锦

  9. 第三十九节,python内置全局变量

    vars()查看内置全局变量 以字典方式返回内置全局变量 #!/usr/bin/env python # -*- coding:utf8 -*- print(vars()) #输出 # {'__bui ...

  10. DOM操作-根据name获取网页中的全部复选框

    描述: 与id不同,多个元素可以使用相同的name属性,如果需要获取这一类元素的DOM对象,就需要使用getElementsByName()函数 代码: <!DOCTYPE html> & ...