# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
573588 |
2022-06-06T21:36:20 Z |
Hanksburger |
Boat (APIO16_boat) |
C++17 |
|
248 ms |
4344 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int dp[1005][505], inv[505], a[505], b[505], c[1005];
set<int> s;
int f(int x, int y)
{
if (!y)
return 1;
int res=f(x, y/2);
if (y&1)
return res*res%mod*x%mod;
else
return res*res%mod;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m=0;
cin >> n;
for (int i=1; i<=n; i++)
inv[i]=f(i, mod-2);
for (int i=1; i<=n; i++)
{
cin >> a[i] >> b[i];
s.insert(a[i]);
s.insert(b[i]+1);
}
for (auto itr=s.begin(); itr!=s.end(); itr++)
c[++m]=(*itr);
for (int i=0; i<=n; i++)
dp[0][i]=1;
for (int i=1; i<m; i++)
{
for (int j=0; j<=n; j++)
{
dp[i][j]=dp[i-1][j];
// cout << "--------- i j " << i << ' ' << j << ' ' << dp[i][j] << '\n';
int num=1, cnt=0;
for (int k=1; k<=j; k++)
{
if (a[j-k+1]<=c[i] && c[i+1]-1<=b[j-k+1])
{
cnt++;
num=num*(c[i+1]-c[i]-cnt+1)%mod*inv[cnt]%mod;
dp[i][j]=(dp[i][j]+dp[i-1][j-k]*num)%mod;
}
// cout << "i j k " << i << ' ' << j << ' ' << k << ' ' << dp[i][j] << '\n';
}
}
}
cout << dp[m-1][n];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
248 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
248 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1136 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
248 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |