【HDU6040】Hints of sd0061(nth_element)
来源:互联网 发布:儿童故事书软件 编辑:程序博客网 时间:2024/06/05 07:29
记录一个菜逼的成长。。
2017 Multi-University Training Contest - Team 1
题目链接
题目大意:
给你
输出排名为
笔记
黑科技:
第一次知道还有这个函数
在
要从大到小选择nth_element,这样复杂度才是接近
#include <bits/stdc++.h>using namespace std;#define rep(i,l,r) for( int i = l; i <= r; i++ )#define rep0(i,l,r) for( int i = l; i < r; i++ )#define ALL(v) (v).begin(),(v).end()#define cl(a,b) memset(a,b,sizeof(a))#define clr clear()#define pb push_back#define mp make_pair#define fi first#define se secondtypedef long long LL;typedef pair<int,int> PII;const int INF = 0x3f3f3f3f;const int maxn = 10000000 + 10;int b[110],c[110],id[110];unsigned a[maxn];unsigned x,y,z;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(int aa,int bb){ return b[aa] < b[bb]; }int main(){ int n,m,cas = 1; while(~scanf("%d%d%u%u%u",&n,&m,&x,&y,&z)){ rep0(i,0,m)scanf("%d",b+i),id[i] = i; rep0(i,0,n)a[i] = rng61(); sort(id,id+m,cmp); b[id[m] = m] = n; for( int i = m - 1; ~i; i-- ){ if (b[id[i]] == b[id[i + 1]]){ c[id[i]] = c[id[i + 1]]; continue; } nth_element(a,a + b[id[i]],a + b[id[i + 1]]); c[id[i]] = a[b[id[i]]]; } printf("Case #%d: ",cas++); for( int i = 0; i < m; i++ )printf("%u%c",c[i]," \n"[i == m-1]); } return 0;}
阅读全文
0 0
- 【HDU6040】Hints of sd0061(nth_element)
- hdu6040 Hints of sd0061【nth_element使用】
- HDU6040-Hints of sd0061
- HDU6040 Hints of sd0061【STL】
- HDU6040-Hints of sd0061(STL)
- hdu 6040 Hints of sd0061(nth_element)
- HDU 6040 Hints of sd0061(nth_element)
- 解题报告:HDU_6040 Hints of sd0061 STL::nth_element
- HDU 6040 Hints of sd0061(STL nth_element函数)
- hdu6040 Hints of sd0061(寻找第b[i]+1小的数)
- Hints of sd0061 HDU
- HDU 6040 Hints of sd0061 找第K大数 (nth_element函数)
- 2017多校一 1008题 hdu 6040 Hints of sd0061 排序 STL nth_element
- 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
- JSON-JavaScript对象表示法--学习笔记
- Dialog整个窗体背景设置为透明
- 【Ubuntu】/mnt/hgfs 权限不够的替代方法
- eclipse新建maven项目,修改默认jdk版本
- 从代码层面优化系统性能应该怎么做?(上)
- 【HDU6040】Hints of sd0061(nth_element)
- TCP之三次握手和四次挥手
- 三种LCA算法(三):转化为LCA问题(dfs+ST表实现)
- Linux关机命令总结
- 电脑windows系统动态壁纸装X器wallpaper engine下载资源和使用教程
- 系统相关功能开发(三)-系统控制与调用
- Android PriorityQueue和PriorityBlockingQueue源码解析
- 关于cocoapods的一些东西
- 你和美女就差一个双眼皮的距离