#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
#define rint register int
#define rep(i,h,t) for (rint i=h;i<=t;i++)
#define dep(i,t,h) for (rint i=t;i>=h;i--)
#define IL inline
const int mo=1e9+7;
const int INF=1e9;
const int N=1e3+10;
int n,jc[N],jc2[N],len[N],a[N],b[N],f[N][N*2],sum[N][N*2],C[N*2][N];
struct re{
int a,b;
}c[N];
IL bool cmp(re x,re y)
{
return x.a<y.a;
}
void gcd(int a,int b,int &x,int &y)
{
if (b==0)
{
x=1; y=0; return;
}
gcd(b,a%b,y,x);
y-=x*(a/b);
}
IL void js(int &x,int y)
{
x+=y;
if (x>=mo) x-=mo;
}
int main()
{
n=500;
jc[0]=1;
rep(i,1,n)
{
int x,y;
gcd(i,mo,x,y);
jc[i]=(1ll*jc[i-1]*x)%mo;
jc2[i]=(1ll*jc2[i-1]*i)%mo;
}
rep(i,1,n)
{
c[i*2-1].a=rand(); c[i*2].a=rand();
if (c[i*2-1].a>c[i*2].a) swap(c[i*2-1].a,c[i*2].a);
c[i*2].a++;
c[i*2-1].b=i*2-1; c[i*2].b=i*2;
}
sort(c+1,c+n*2+1,cmp);
int cnt=0;
c[0].a=INF;
rep(i,1,n*2)
{
if (c[i].a!=c[i-1].a) cnt++,len[cnt]=c[i].a-c[i-1].a;
if (c[i].b%2) a[(c[i].b+1)/2]=cnt+1;
else b[c[i].b/2]=cnt;
}
int m=cnt;
for (int i=1;i<=m;i++)
{
int p=1;
C[i][0]=1;
for (int j=1;j<=n+1;j++)
p=(1ll*p*(len[i]+j-1))%mo,C[i][j]=((1ll*p*jc[j])%mo+mo)%mo;
}
f[0][0]=1;
rep(i,0,m) sum[0][i]=1;
int ans=0;
rep(i,1,n)
{
rep(j,a[i],b[i])
{
rint kk=0;
dep(k,i-1,0)
{
rint now=sum[k][j-1];
if (now) js( f[i][j],(1ll*now*C[j][kk+1])%mo);
if (a[k]<=j&&j<=b[k]) kk++;
}
sum[i][j]=sum[i][j-1]+f[i][j];
if (sum[i][j]>=mo) sum[i][j]-=mo;
js(ans,f[i][j]);
}
rep(j,b[i]+1,m) sum[i][j]=sum[i][j-1];
}
printf("%d",(ans+mo)%mo);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 374.637 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #2 | 374.691 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #3 | 374.882 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 374.69 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #5 | 374.757 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #6 | 374.742 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #7 | 374.688 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #8 | 375.263 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #9 | 374.62 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #10 | 374.782 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #11 | 375.156 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #12 | 374.689 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #13 | 374.559 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #14 | 374.714 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #15 | 374.705 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #16 | 374.674 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #17 | 374.536 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #18 | 374.701 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #19 | 374.872 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #20 | 374.597 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #21 | 374.688 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #22 | 374.667 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #23 | 374.463 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #24 | 374.71 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #25 | 374.588 ms | 9 MB + 680 KB | Wrong Answer | Score: 0 | 显示更多 |