博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT (Advanced Level) 1109. Group Photo (25)
阅读量:7255 次
发布时间:2019-06-29

本文共 832 字,大约阅读时间需要 2 分钟。

简单模拟。

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;struct X{ string name; int h;} s[100000+10];int n,k;vector
g[200];int tmp[10000+10];bool cmp(const X&a,const X&b){ if(a.h==b.h) return a.name
b.h;}int main(){ scanf("%d%d",&n,&k); for(int i=1; i<=n; i++) cin>>s[i].name>>s[i].h; sort(s+1,s+n+1,cmp); int t=n+1; for(int i=k; i>=1; i--) { int m; if(i>1) m=n/k; else m=n-n/k*(k-1); t=t-m; int y=t,p=m/2+1,sz=0; int L,R; tmp[p]=y++,sz++,L=p-1,R=p+1; while(1) { if(sz==m) break; if(sz%2==0) tmp[R++]=y++; else tmp[L--]=y++; sz++; } for(int j=1;j<=m;j++) g[i].push_back(tmp[j]); } for(int i=1; i<=k; i++) { for(int j=0; j

 

转载于:https://www.cnblogs.com/zufezzt/p/5644689.html

你可能感兴趣的文章
.NET跨平台:在Linux上基于ASP.NET 5用EF7生成数据库
查看>>
DataProtection设置问题引起不同ASP.NET Core站点无法共享用户验证Cookie
查看>>
Windows 上编译 corefx 源码生成 Linux 上可用的 System.Data.SqlClient.dll
查看>>
Sublime python 環境配置和交互加載
查看>>
Android Touch事件传递机制 一: OnTouch,OnItemClick(监听器),dispatchTouchEvent(伪生命周期)...
查看>>
十进制到62进制的转换
查看>>
python 后台运行命令
查看>>
【IOS】读取、保存图片的各种方法
查看>>
CCNA第二章
查看>>
CCNP路 由 选 择 原 理
查看>>
input 特殊字符限制
查看>>
ubuntu14.04配置python 配置OPENCV
查看>>
String类的subString(i)方法(基于jdk 1.9)
查看>>
Java并发包--ConcurrentLinkedQueue
查看>>
vue.js组件命名
查看>>
python------栈和队列的实现
查看>>
Css选择器定位详解
查看>>
selenium入门基础知识
查看>>
并查集的一般操作 ④
查看>>
Altium Designer 19使用
查看>>