https://codeforces.com/contest/1288/problem/E
思路参考:
https://www.luogu.com.cn/blog/_post/205868
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=6e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL tree[maxn];
LL l[maxn],r[maxn],pos[maxn*2];
void add(LL x,LL d){
while(x<maxn){
tree[x]+=d;
x+=lowbit(x);
}
}
LL query(LL x){
LL sum=0;
while(x>0){
sum+=tree[x];
x-=lowbit(x);
}return sum;
}
int main(void){
cin.tie(0);std::ios::sync_with_stdio(false);
LL n,m;cin>>n>>m;
for(LL i=1;i<=n;i++){
l[i]=r[i]=i;pos[i]=i+m;
add(pos[i],1);
}
LL last=m;
while(m--){
LL x;cin>>x;l[x]=1;
r[x]=max(r[x],query(pos[x]));
add(pos[x],-1);
pos[x]=last--;
add(pos[x],1);
}
for(LL i=1;i<=n;i++){
r[i]=max(r[i],query(pos[i]));
}
for(LL i=1;i<=n;i++){
cout<<l[i]<<" "<<r[i]<<"\n";
}
return 0;
}