简单模拟。

#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. 【Python之路】第一篇--Linux基础命令

    pwd 命令 查看”当前工作目录“的完整路径 pwd -P # 显示出实际路径,而非使用连接(link)路径:pwd显示的是连接路径 .   表示当前目录 ..  表示上级目录 /  表示根目录 ls ...

  2. Mysql CPU占用高的问题解决方法小结

    通过以前对mysql的操作经验,先将mysql的配置问题排除了,查看msyql是否运行正常,通过查看mysql data目录里面的*.err文件(将扩展名改为.txt)记事本查看即可.如果过大不建议用 ...

  3. 创建简单动画(一) --- 常规hud

    先说下当前我为处理动画的思路: (新手上路, 老司机轻喷,如果有更好的实现方法请大神指教 感恩戴德) #1. 分析动画构成 #2. 如果是位移动画则考虑使用BasicAnimation或者Keyfra ...

  4. 好玩的获取目录信息的例子[C#]

    DirectoryInfo dirinfo = new DirectoryInfo("d:\\111"); DirectoryInfo[] dirs = dirinfo.GetDi ...

  5. linux文件特殊属性介绍(s,s,t)

    文件的权限有rwx这3个读.写.执行的权限.但是,怎么 /tmp权限有些奇怪?还有, /usr/bin/passwd也有些奇怪,怎么回事呢? [root@linux ~]# ls -ld /tmp ; ...

  6. python--sorted函数

    摘自:http://www.cnblogs.com/65702708/archive/2010/09/14/1826362.html 我们需要对List进行排序,Python提供了两个方法对给定的Li ...

  7. ios 中NSArray

    // #import <Foundation/Foundation.h> #import "Animal.h" int main(int argc, const cha ...

  8. iOS申请真机调试证书 -- 图文详解

    请参考这篇文章 : http://ios.9tech.cn/news/2013/1011/33117.html 这篇文章完全就是对的,主要是最后一步 “配置Xcode" 图没有配全,也配得不 ...

  9. Ubuntu 14.04 Nvidia显卡驱动手动安装及设置

      更换主板修复grub 引导后,无法从Nvidia进入系统(光标闪烁), 可能是显卡驱动出了问题. 1. 进入BIOS设置, 从集成显卡进入系统 将显示器连接到集显的VGI口, 并在BIOS中设置用 ...

  10. Entity Framework 学习高级篇1—改善EF代码的方法(上)

    本节,我们将介绍一些改善EF代码的相关方法,如NoTracking,GetObjectByKey, Include等. l         MergeOption.NoTracking 当我们只需要读 ...