hdu 6040 Hints of sd0061(STL)

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 mm coming contests. sd0061 has left a set of hints for them.

There are nn noobs in the team, the ii-th of which has a rating aiai. sd0061 prepares one hint for each contest. The hint for the jj-th contest is a number bjbj, which means that the noob with the (bj+1)(bj+1)-th lowest rating is ordained by sd0061 for the jj-th contest.

The coach asks constroy to make a list of contestants. constroy looks into these hints and finds out: bi+bj≤bkbi+bj≤bk is satisfied if bi≠bj,bi≠bj, bi

#include <bits/stdc++.h>
using namespace std;

const int N = 1e7+8;
unsigned a[N];
int n,m;
unsigned x,y,z;

struct node
{
    int id,k;
}pi[110];

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 cmp(node a,node b)
{
    return a.k<b.k;
}

int ans[120];
int main()
{
    int T=1;
    while(cin>>n>>m>>x>>y>>z)
    {
        for(int i=0;i<n;i++) a[i]=rng61();
        for(int i=0;i<m;i++) cin>>pi[i].k,pi[i].id=i;
        sort(pi,pi+m,cmp);
        pi[m].k=n;pi[m].id=m;
        for(int i=m-1;i>=0;--i)
        {
            if(pi[i].k==pi[i+1].k)
            {
                ans[pi[i].id]=ans[pi[i+1].id];
                continue;
            }
            nth_element(a,a+pi[i].k,a+pi[i+1].k);
            ans[pi[i].id]=a[pi[i].k];
        }
         printf("Case #%d:",T++);
         for(int i=0;i<m;i++) cout<<" "<<ans[i];
         printf("%s\n", );
    }
}
posted @ 2017-09-19 21:18  黑码的博客  阅读(134)  评论(0编辑  收藏  举报