专栏文章

[题解]P14574 批话哥

P14574题解参与者 2已保存评论 2

文章操作

快速查看文章及其快照的属性,并进行相关操作。

当前评论
2 条
当前快照
1 份
快照标识符
@mip15x0b
此快照首次捕获于
2025/12/03 04:28
3 个月前
此快照最后确认于
2025/12/03 04:28
3 个月前
查看原文

思路

因为题目保证了 (xi,yi)(x_i,y_i) 互不相同,所以说这个 yy 没有任何作用。
然后接下来就是纯模拟了,当 vlv \leq lansxans_x100100 ;当 l<v<rl < v < ransxans_x 加上 vv;其余情况 ansxans_x 不变即可。

Code

CPP
#include <bits/stdc++.h>
#define re register

using namespace std;

const int N = 3e5 + 10;
int n,m,k,l,r;
int ans[N];

inline int read(){
    int r = 0,w = 1;
    char c = getchar();
    while (c < '0' || c > '9'){
        if (c == '-') w = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9'){
        r = (r << 3) + (r << 1) + (c ^ 48);
        c = getchar();
    }
    return r * w;
}

int main(){
    n = read(),m = read(),k = read(),l = read(),r = read();
    for (re int i = 1,x,y,v;i <= k;i++){
        x = read(),y = read(),v = read();
        if (v <= l) ans[x] += 100;
        else if (v < r) ans[x] += v;
    }
    for (re int i = 1;i <= n;i++) printf("%d ",ans[i]);
    return 0;
}

评论

2 条评论,欢迎与作者交流。

正在加载评论...