GDCPC

102 阅读1分钟

D

Recently, Jvruo​ became obsessed with a fighting game. In this game, n​ characters stand on an arena from left to right, and the combat power of the ith​ character is aia_iai​. For each operation, Jvruo​ will choose two adjacent characters x​ and y​ on the arena for a duel. If ax​>ay​, then x​ wins, if ax​<ay​, then y​ wins. If ax​=ay​, then both x​ and y​ have a probability of 50%50%50% to win. The victorious character will stay in the arena and double the combat power; the losing character will leave the arena.

Now Jvruo​ will perform n−1​ operations, after n−1​ operations, there will only be one character left in the ring. Obviously, Jvruo​ has  (n−1)! operation modes. In all these modes of operation, which characters have the probability to stay till the end and become the final winner.

题意:让你每次相邻的两个进行比较,大的他的能量就翻倍,问有多少个可能获得冠军

思路:其实暴力直接模拟一遍就可以了

void solve()
{
    int mx = 0;
    cin >> n;
    for(int i = 1;i <= n;i ++)
    {
        cin >> a[i];
        mx = max(mx,a[i]);
        c[i] = max(c[i-1],a[i]);
    }
    for(int i = n;i >= 1;i --)
        d[i] = max(d[i+1],a[i]);
    for(int i = 1;i <= n;i ++)
        cout << d[i] << " \n"[i == n];
    for(int i = 1;i <= n;i ++)
        cout << c[i] << " \n"[i == n];
    vector<int>ans;
    for(int i = 1;i <= n;i ++)
    {
        if(a[i]==mx)
        {
            ans.push_back(i);
            continue;
        }
        int res = i-1,pos = i + 1,w = a[i];
        cout << w << '\n';
        while(1)
        {
            if(w > a[pos]&&pos<=n)
            {
                w*=2;
                cout << w << '\n';
                pos++;
                if(w>=d[pos])
                {
                    for(int i = pos;i <= n;i ++)
                    {
                        w*=2;
                        cout << w << '\n';
                        if(w >= mx)
                            break;
                    }
                }
            }
            if(w >= mx)
                break;
            if(w >= a[res]&&res>= 1)
            {
                w*=2;
                res--;
                if(w>=c[res])
                {
                    for(int i = res;i >=1;i --)
                    {
                        w*=2;
                        if(w >= mx)
                            break;
                    }
                }
            }
            if(w >= mx)
                break;
            if(w<a[res]&&w<a[pos])
                break;
            if(res<1&&pos>n)
                break;
        }
        cout << '\n';
        if(w>=mx)
             ans.push_back(i);
    }
    cout << ans.size() << '\n';
    for(auto c:ans)
        cout << c << ' ';
    cout << '\n';
} 

A

Measuring the area of a certain shape is an important part of certain geometric problems. 

For a point A(x,y)​ on the plane, we define the F(x,y)​ as ∣x∣∗∣y∣​,which means the area of the rectangle with the vertex(x,0),(0,y),(0,0),(x,y)​.

You are given  n∗m​ vertex with integral coordinates in the form of (i,j)​,and 1≤i≤n,1≤j≤m. You need to find the K-th biggest value of F(i,j)​,when 1≤i≤n,1≤j≤m.

It's guranteed that K≤n∗m.

思路:题意很好理解,用优先队列模拟一遍就可以了

代码:

void solve()
{
    cin >> n >> m >> k;
    priority_queue<now> q;
    for(int i = 1;i <= n;i ++)
    {
        e.nn = i;
        e.mm = m;
        e.sum = i*m;
        q.push(e);
    }
    for(int i = 1;i <= k;i ++)
    {
        auto s = q.top();
        if(i == k)
        {
            cout << s.sum << '\n';
            return;
        }
        q.pop();
        s.mm--;
        s.sum = s.mm*s.nn;
        q.push(s);
    }
}