HDU 6040---Hints of sd0061(STL)
2018-06-17 22:10:38来源:未知 阅读 ()
题目链接
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<bk and bj<bk.
Now, you are in charge of making the list for constroy.
For each test case:
The first line contains five integers n,m,A,B,C. (1≤n≤107,1≤m≤100)
The second line contains m integers, the i-th of which is the number bi of the i-th hint. (0≤bi<n)
The n noobs' ratings are obtained by calling following function n times, the i-th result of which is ai.
unsigned x = A, y = B, z = C;
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;
}
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; const int N=1e7+5; unsigned x,y,z, A,B,C; unsigned a[N]; struct Node { int x; int id; unsigned y; }tr[105]; bool cmp(const Node s1,const Node s2) { return s1.x<s2.x; } bool cmp2(const Node s1,const Node s2) { return s1.id<s2.id; } 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; } int main() { ///cout << "Hello world!" << endl; int n,m,Case=1; while(scanf("%d%d%u%u%u",&n,&m,&A,&B,&C)!=EOF) { x = A, y = B, z = C; for(int i=0;i<n;i++) a[i]=rng61(); printf("Case #%d:",Case++); for(int i=1;i<=m;i++) scanf("%d",&tr[i].x),tr[i].id=i; sort(tr+1,tr+m+1,cmp); int p=n; for(int i=m;i>=1;i--) { int x = tr[i].x; nth_element(a,a+x,a+p); p=x; tr[i].y=a[x]; } sort(tr+1,tr+m+1,cmp2); for(int i=1;i<=m;i++) printf(" %u",tr[i].y); puts(""); } return 0; }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:0-1背包问题(the knapsack problem)
下一篇:函数
- HDU-2955-Robberies(0-1背包) 2020-03-30
- hdu1455 拼木棍(经典dfs) 2020-02-29
- anniversary party_hdu1520 2020-02-16
- hdu1062 text reverse 2020-01-27
- hdu4841 2020-01-26
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash