【HDU 6040 Hints of sd0061】 思维 & STL
来源:互联网 发布:淘宝爱玩电玩数码店 编辑:程序博客网 时间:2024/06/13 21:22
Hints of sd0061
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2379 Accepted Submission(s): 721
Problem Description
sd0061, the legend of Beihang University ACM-ICPC Team, retired last year leaving a group of noobs. Noobs have no idea how to deal with m coming contests. sd0061 has left a set of hints for them.
There are n noobs in the team, the i-th of which has a rating ai. sd0061 prepares one hint for each contest. The hint for the j-th contest is a number bj, which means that the noob with the (bj+1)-th lowest rating is ordained by sd0061 for the j-th contest.
The coach asks constroy to make a list of contestants. constroy looks into these hints and finds out: bi+bj≤bk is satisfied if bi≠bj, bi
#include<bits/stdc++.h>using namespace std;struct node{ int b,o; unsigned a;}st[110];const int MAX = 1e7 + 10;unsigned x,y,z,a[MAX];unsigned rng61() { unsigned t; x ^= x << 16; x ^= x >> 5; x ^= x << 1; t = x; x = y; y = z; z = t ^ x ^ y; return z;}bool cmp(node i,node j) { return i.b < j.b; }bool cnp(node i,node j) { return i.o < j.o; }int main(){ int n,m,nl = 0; while(~scanf("%d %d %u %u %u",&n,&m,&x,&y,&z)){ for(int i = 0; i < n; i++) a[i] = rng61(); for(int i = 0; i < m; i++) scanf("%d",&st[i].b),st[i].o = i; sort(st,st + m,cmp); int pl = n; for(int i = m - 1; i >= 0; i--){ int b = st[i].b; nth_element(a,a + b,a + pl); // 在 a ~ a + pl 数组里找到第 b + 1 小的数 pl = b; st[i].a = a[b]; } sort(st,st + m,cnp); printf("Case #%d:",++nl); for(int i = 0; i < m; i++) printf(" %u",st[i].a); puts(""); } return 0;}
- 【HDU 6040 Hints of sd0061】 思维 & STL
- HDU 6040 Hints of sd0061 STL
- hdu 6040 Hints of sd0061(STL)
- hdu 6040 Hints of sd0061(STL)
- HDU 6040 Hints of sd0061 stl
- HDU 6040 Hints of sd0061
- [HDU]-6040 Hints of sd0061
- HDU 6040 Hints of sd0061
- HDU-6040 Hints of sd0061
- hdu 6040 Hints of sd0061
- hdu 6040 Hints of sd0061
- hdu 6040 Hints of sd0061【STL线性排序函数】
- HDU 6040 Hints of sd0061(STL nth_element函数)
- 【多校训练】hdu 6040 Hints of sd0061 STL
- Hints of sd0061 HDU
- HDU 6040 Hints of sd0061 (技巧)
- hdu 6040 Hints of sd0061(nth_element)
- HDU 6040 Hints of sd0061(nth_element)
- [转载]整数读入优化 C++
- Android 不通过USB数据线调试
- hadoop-2.8编译以及集群安装
- linux防火墙基础及iptables数据流
- php 根据标签的属性值来爬取内容的正则表达式
- 【HDU 6040 Hints of sd0061】 思维 & STL
- Hbase的常用shell操作
- js进度条
- 【2017多校】HDU6058 Kanade's sum 【链表】
- Best_Time_to_Buy_and_Sell_Stock_II
- 简单说明Oracle数据库中对死锁的查询及解决方法
- 环境培训资源链接
- 钓鱼网站+邮件诈骗 实例分析
- JSPs only permit GET POST or HEAD的解决方案(REST风格)