简单模拟。

#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. ejabberd模块开发

    参考: http://anders.conbere.org/journal/ http://www.process-one.net/en/wiki/ejabberd_module_developmen ...

  2. 2015 Multi-University Training Contest 7

    1001 Game On the Tree 1002 Tree Maker 1003 Hotaru's problem Manacher处理好p数组. 暴力举一下公共串即可. # include &l ...

  3. ***1133. Fibonacci Sequence(斐波那契数列,二分,数论)

    1133. Fibonacci Sequence Time limit: 1.0 secondMemory limit: 64 MB is an infinite sequence of intege ...

  4. spring配置文件详解【总结】

    知其然,知其所以然 <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns=&qu ...

  5. VMWare网络链接三种方式

    本文转自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/03/15/1985084.html VMware虚拟机上网络连接(networ ...

  6. 移动前端不得不了解的HTML5 head 头标签(中下篇)

    SEO 优化部分 页面标题<title>标签(head 头部必须)        <title>your title</title>    页面关键词 keywor ...

  7. C# WebRequest简单调用WebService方法

    //get string res = GetStringByUrl("http://你的地址/WebService.asmx/方法名?参数=1"); //post string r ...

  8. linux上安装配置samba服务器

    linux上安装配置samba服务器 在linux上安装配置samba服务器 在这给大家介绍一个不错的家伙,samba服务.如果您正在犯愁,如何在Windows和Linux之间实现资源共享,就请看看这 ...

  9. OpenCV使用边缘提取、腐蚀、轮廓进行车牌定位

    http://blog.csdn.net/superdont/article/details/24935383 OpenCV使用边缘提取.腐蚀.轮廓进行车牌定位 2014-05-03 21:38 67 ...

  10. glusterfs——volume管理

    Q: 常用的命令有哪些? 创建volume: gluster volume create NAME stripe SCOUNT replica RCOUNT transport TYPE  BRICK ...