跳到正文

题解

[题解]S4OI Round1 批话哥

WaterSun约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月24日
篇幅
约 2 分钟

版本

  1. v1当前

思路

因为题目保证了 (xi,yi)(x_i,y_i) 互不相同,所以说这个 yy 没有任何作用。

然后接下来就是纯模拟了,当 v≤lv \leq l 时 ansxans_x 不变;当 l<v<rl < v < r 时 ansxans_x 加上 vv;其余情况 ansxans_x 加 100100 即可。

Code

C++
#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;
}
原文