2023 (ICPC) Jiangxi Provincial Contest -- Official Contest

2023 (ICPC) Jiangxi Provincial Contest -- Official Contest

L:Zhang Fei Threading Needles - Thick with Fine

题意:签到,输出n - 1

void solve(){
    ll n;
    cin >> n;
    cout << n - 1 << '\n';
}

A. Drill Wood to Make Fire

题意:签到,b * c >= a

void solve(){
    ll a, b, c;
    cin >> a >> b >> c;
    cout << (b * c >= a ? 1 : 0) << '\n';
}

I. Tree

题意:一棵树,两种操作:1:给定路径(u, v)和一个数字x,将路径上所有边权异或一x;2:求一个点所有相连的边的异或和

思路:直接处理答案就行,由于异或的性质,只会对u,v产生影响,模拟即可

ll n, q;
ll ans[N];

void solve(){
    cin >> n >> q;
    for(int i = 1; i < n; i ++){
        ll u, v, w;
        cin >> u >> v >> w;
        ans[u] ^= w;
        ans[v] ^= w;
    }
    while(q --){
        int op, x, y, z;
        cin >> op;
        if(op == 1){
            cin >> x >> y >> z;
            ans[x] ^= z;
            ans[y] ^= z;
        }
        else{
            cin >> x;
            cout << ans[x] << '\n';
        }
    }
}

J. Function

题意:在每个点放一个二次函数,两种操作:1:添加一个二次函数;2:询问所有的函数在x = a时候的最小值

思路:观察函数可以发现是一个指数爆炸的增长,从给定的点枚举sqrt(n)个即可

void solve(){
    ll n, len;
    cin >> n;
    len = sqrt(n);
    vector<ll> b(n + 1);
    for(int i = 1; i <= n; i ++) cin >> b[i];
    ll m;
    cin >> m;
    while(m --){
        ll op;
        cin >> op;
        if(op == 0){
            ll x, y;
            cin >> x >> y;
            b[x] = min(b[x], y);
        }
        else{
            ll x;
            cin >> x;
            ll ans = 1e18;
            for(ll i = max(1ll, x - len); i <= min(n, x + len); i ++){
                ans = min(ans, (x - i) * (x - i) + b[i]);
            }
            cout << ans << '\n';
        }
    }
}

K. Split

题意:给定一个长度为n的单调不升序列,给定一个操作数m,两种操作:1:将 a[x] -> a[x - 1] + a[x + 1] - a[x],2:求将序列分为k段,每一段的max - min的最小价值合

思路:先考虑第二个操作:当将数组从i, i + 1分开,贡献就是

 

pending。。。。。。

posted @ 2024-05-15 21:38  Rosmontis_L  阅读(11)  评论(0编辑  收藏  举报