显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ROOT 1,1,n
#define LSON root<<1,l,mid
#define RSON root<<1|1,mid+1,r
using namespace std;
const int maxn=10000+5;
struct node
{
int x,y;
bool operator <(node p) const
{
if(x<p.x) return true;
if(x>p.x) return false;
return y<p.x;
}
}a[maxn];
int b[maxn],c[maxn];
int n,pos,h,r;
void build(int root,int l,int r);
int main()
{
freopen("tallest.in","r",stdin);
freopen("tallest.out","w",stdout);
scanf("%d%d%d%d",&n,&pos,&h,&r);
for(int i=1; i<=r; i++)
{
int x,y;
scanf("%d %d",&x,&y);
if(x>y) swap(x,y);
a[i].x=x; a[i].y=y;
}
sort(a+1,a+r+1);
int tmp1=0,tmp2=0;
for(int i=1; i<=r; i++)
{
int x=a[i].x,y=a[i].y;
if(x!=tmp1 || y!=tmp2)
{
tmp1=x; tmp2=y;
c[x+1]--; c[y]++;
}
}
for(int i=1; i<=n; i++)
{
c[i]+=c[i-1];
b[i]=h+c[i];
}
for(int i=1; i<=n; i++)
{
printf("%d\n",b[i]);
}
return 0;
}