# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
95326 |
2019-01-30T07:58:46 Z |
tduong0806 |
Boat (APIO16_boat) |
C++14 |
|
6 ms |
4344 KB |
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define all(a) a.begin(),a.end()
#define pb push_back
const int N=1010,mod=1e9+7;
int n,f[N][N],a[N],b[N],old[N],s[N][N],m;
vector<int> e;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
//freopen("BOAT.inp","r",stdin);
//freopen("BOAT.out","w",stdout);
cin>>n;
forinc(i,1,n)
{
cin>>a[i]>>b[i];
e.pb(a[i]);e.pb(b[i]);
}
e.erase(unique(all(e)),e.end());
m=e.size();
forinc(i,0,m-1)
{
old[i+1]=e[i];
a[i]=lower_bound(all(e),a[i])-e.begin()+1;
b[i]=lower_bound(all(e),b[i])-e.begin()+1;
}
old[m+1]=1e9;
f[0][0]=1;
forinc(j,0,m) s[0][j]=1;
forinc(i,1,n) forinc(j,0,m)
{
f[i][j]=(f[i][j]+f[i-1][j])%mod;
if(j>=a[i]&&j<=b[i])
{
int c=min(old[b[i]],old[j+1]-1);
f[i][j]=(f[i][j]+s[i-1][j-1]*(c-old[j]+1))%mod;
}
s[i][j]=s[i][j-1]+f[i][j];
}
cout<<s[n][m]-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |