#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
re int t=0;re char v=getchar();
while(v<'0')v=getchar();
while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
return t;
}
const int M=998244353;
inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
inline int Mod(re int x){return x>=M?x-M:x;}
inline int ksm(re int x,re int y){
re int s=1;
while(y){
if(y&1)s=1ll*s*x%M;
x=1ll*x*x%M,y>>=1;
}
return s;
}
int t,n,m,a[1000002],ans,A[1000002],B[1000002],R[1000002],stk[1000002],tp,k,f[1000002],g[4004][4002];
char s[1000002];
int main(){
n=read(),m=read();
for(re int i=1;i<=m;++i)A[i]=read(),B[i]=read(),R[i]=A[i],R[i+m]=B[i]+1;
k=m+m,R[++k]=1,R[++k]=n+1;
sort(R+1,R+k+1),k=unique(R+1,R+k+1)-R-1;
if(k==2){
printf("0 %d\n",m);
return 0;
}
for(re int i=1;i<k-1;++i)for(re int j=1;j<=m;++j)if(((A[j]<=R[i]&&B[j]>=R[i+1]-1)||(A[j]<=R[i+1]&&B[j]>=R[i+2]-1))&&((!(A[j]<=R[i]&&B[j]>=R[i+2]-1))))f[i]+=2;
memset(g,0x3f,sizeof(g)),g[1][0]=0;
for(re int i=1;i<k;++i)
for(re int j=0;j<=i;++j)
g[i+1][j]=min(g[i+1][j],g[i][j]),
g[i+2][j+1]=min(g[i+2][j+1],g[i][j]+f[i]);
re int d=1,c=0;
while(d<k-1)d<<=1,++c;
printf("%d %d",c,g[k][(k-1)-(d>>1)]);
}
./Main.cpp: In function ‘int read()’:
./Main.cpp:5:9: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
5 | re int t=0;re char v=getchar();
| ^
./Main.cpp:5:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
5 | re int t=0;re char v=getchar();
| ^
./Main.cpp: At global scope:
./Main.cpp:11:25: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
11 | inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
| ^
./Main.cpp:11:34: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
11 | inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
| ^
./Main.cpp:12:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
12 | inline int Mod(re int x){return x>=M?x-M:x;}
| ^
./Main.cpp:13:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
13 | inline int ksm(re int x,re int y){
| ^
./Main.cpp:13:32: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
13 | inline int ksm(re int x,re int y){
| ^
./Main.cpp: In function ‘int ksm(int, int)’:
./Main.cpp:14:9: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
14 | re int s=1;
| ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:25:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
25 | for(re int i=1;i<=m;++i)A[i]=read(),B[i]=read(),R[i]=A[i],R[i+m]=B[i]+1;
| ^
./Main.cpp:32:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
32 | for(re int i=1;i<k-1;++i)for(re int j=1;j<=m;++j)if(((A[j]<=R[i]&&B[j]>=R[i+1]-1)||(A[j]<=R[i+1]&&B[j]>=R[i+2]-1))&&((!(A...