首页 > 其他分享 >The 2021 CCPC Weihai Onsite E CHASE!

The 2021 CCPC Weihai Onsite E CHASE!

时间:2022-12-02 11:57:49浏览次数:64  
标签:Onsite cout Weihai int sum eps len CHASE

CHASE!

概率 \(dp\) + 双指针

占个坑,说明补了这题,题解没时间写了,先咕咕了

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps = 1e-8;

int dcmp(double x)
{
    return (x > eps) - (x < -eps);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q, k;
    cin >> n >> k >> q;
    vector<ll>a(n + 1), sum(n + 1, 0);
    for(int i=1; i<=n; i++) cin >> a[i];
    vector<ll> b = a;
    sort(a.begin() + 1, a.end());
    for(int i=1; i<=n; i++) sum[i] = sum[i - 1] + a[i];
    vector<double>E(k + 1);
    for(int i=1; i<=n; i++) E[0] += (n - 1) * a[i];
    E[0] /= 1ll * n * (n - 1) / 2;
    for(int i=1; i<=k; i++)
    {
        double p = E[0], tot = 0;
        int l = 1, r = n;
        ll cnt = 0;
        while(l <= n)
        {
            while(r >= l && a[r] + a[l] >= E[i - 1]) r--;
            if(l > r) break;
            ll len = r - l;
            p -= (len * a[l] + sum[r] - sum[l]) / (1.0 * n * (n - 1)) * 2;
            tot += len;
            l++;
        }
        p += E[i - 1] / (1ll * n * (n - 1)) * 2 * tot;
        E[i] = p;
    }
    cout << fixed << setprecision(20) << E[k] << "\n";
    while(q--)
    {
        ll x, y, c;
        cin >> x >> y >> c;
        if(c == 0) cout << "accept\n";
        else
        {
            int dif = dcmp(b[x] + b[y] - E[c - 1]);
            if(dif == 0) cout << "both\n";
            else if(dif == 1) cout << "accept\n";
            else cout << "reselect\n";
        }
    }
    return 0;
}

标签:Onsite,cout,Weihai,int,sum,eps,len,CHASE
From: https://www.cnblogs.com/dgsvygd/p/16944009.html

相关文章

  • 2022ccpc绵阳(2022 China Collegiate Programming Contest (CCPC) Mianyang Onsite)
    链接:https://codeforces.com/gym/104065A#include"bits/stdc++.h"usingnamespacestd;usingi64=longlong;constexprintN=2E5;boolvis[N+10][11][11......
  • The 2021 CCPC Guilin Onsite (XXII Open Cup, Grand Prix of EDG
    https://codeforces.com/gym/103409/problem/BB.APlusBProblem—————数据结构(set)题意给你两个n位的数a,b(有前导零),c是a+b的结果(最高位的进位已省略)q次询......
  • [Editorial] 2022 CCPC Guangzhou Onsite
    2022CCPCGuangzhouOnsite大概按题目难度顺序排序。这篇题解可能没那么口胡。GYM104053EElevator相当于每个电梯在\(-x_i\),每次可以把最大的,编号最小的值减一,要求......
  • 2022 China Collegiate Programming Contest (CCPC) Guangzhou Onsite I
    I.Infectionn=2000,我们考虑dp我们转化题意发现就是找一个连通子块然后连通块的权重就是其中任何一个点的a[i]其他都是p[i]但是对于连通块相接的点我们都要让他是(1-......
  • 2022 China Collegiate Programming Contest (CCPC) Weihai Site
    比赛链接:https://codeforces.com/gym/104023A.Dunai题意:\(n\)个队伍获得过冠军,告知每个队伍中的人及对应的位置,现在已知\(m\)个选手及它们的位置,问能组成多少个五......
  • CCPC 2022 Weihai
    下饭场。中间有几个题因为很sb的原因卡了很久,罚时炸了,而且最后F调了40min没调出来,差两名Au。ADunai记参赛选手中有\(k\)个曾经夺得冠军,5个位置上的选手分别有......
  • P4657 Chase
    一种和其他题解不同的dp定义发现其他题解是四倍空间选和不选最大次大因为比较恶心所以我们考虑直接强制这个点不选当其他点dp到它时再考虑它自己码量很小也简洁易......