AcWing 101. 最高的牛
题解
Code
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#include <unordered_map>
#define ll long long
#define ull unsigned long long
#define re return
#define pb push_back
#define Endl "\n"
#define endl "\n"
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int M = 1e5 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
int T;
int n, p, h, m;
int a[N];
set<PII> s;
void solve(){
cin >> n >> p >> h >> m;
for (int i = 1; i <= n; i++){
a[i] = h;
}
for (int i = n; i >= 1; i--)
a[i] -= a[i - 1];
while(m--){
int x, y;
cin >> x >> y;
if(x > y)
swap(x, y);
s.insert({x, y});
}
for(auto i : s){
a[i.x + 1] += -1;
a[i.y] -= -1;
}
for (int i = 1; i <= n; i++){
a[i] += a[i - 1];
cout << a[i] << endl;
}
}
int main(){
T = 1;
// cin >> T;
while(T--){
solve();
}
}