# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
106654 |
2019-04-19T11:48:37 Z |
username |
Boat (APIO16_boat) |
C++14 |
|
14 ms |
8448 KB |
#pragma GCC optimize("O3")
#include<stdint.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
/*****************************************************************************/
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
// #define __debug
#ifdef __debug
#define IOS (void)0
#define de(...) cerr<<__VA_ARGS__
#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
#define de(...) (void)0
#define ar(...) (void)0
#endif
/***********************************default***********************************/
const int maxn=509,mo=1e9L+7;
int n,q=0,a[maxn],b[maxn],dp[maxn][2*maxn],sum[maxn][2*maxn];
pii p[2*maxn];
main(){
IOS;
cin>>n;
p[q++]=pii(0,0);
REP(i,0,n)cin>>a[i]>>b[i],++b[i],p[q++]=pii(a[i],0),p[q++]=pii(b[i],0);
sort(p,p+q);
q=unique(p,p+q)-p;
REP(i,0,q)p[i].S=i;
REP(i,0,n)a[i]=lower_bound(p,p+q,pii(a[i],0))->S,b[i]=lower_bound(p,p+q,pii(b[i],0))->S;
MST(dp[0],0);
dp[0][0]=1;
fill(sum[0],sum[0]+q,1);
REP(i,0,n){
REP(j,0,q)dp[i+1][j]=dp[i][j];
REP(j,a[i],b[i])dp[i+1][j]=sum[i][j];
sum[i+1][0]=dp[i+1][0];
REP(j,1,q)sum[i+1][j]=(sum[i+1][j-1]+dp[i+1][j])%mo;
}
int res=0;
REP(i,1,q)res=(res+dp[n][i]*(p[i+1].F-p[i].F))%mo;
cout<<res<<endl;
}
Compilation message
boat.cpp:46:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
8320 KB |
Output is correct |
2 |
Correct |
10 ms |
8320 KB |
Output is correct |
3 |
Correct |
10 ms |
8320 KB |
Output is correct |
4 |
Correct |
11 ms |
8320 KB |
Output is correct |
5 |
Correct |
12 ms |
8320 KB |
Output is correct |
6 |
Correct |
14 ms |
8320 KB |
Output is correct |
7 |
Correct |
13 ms |
8320 KB |
Output is correct |
8 |
Correct |
12 ms |
8320 KB |
Output is correct |
9 |
Correct |
11 ms |
8320 KB |
Output is correct |
10 |
Correct |
11 ms |
8320 KB |
Output is correct |
11 |
Correct |
11 ms |
8320 KB |
Output is correct |
12 |
Correct |
11 ms |
8320 KB |
Output is correct |
13 |
Correct |
11 ms |
8448 KB |
Output is correct |
14 |
Correct |
13 ms |
8320 KB |
Output is correct |
15 |
Correct |
10 ms |
8320 KB |
Output is correct |
16 |
Correct |
12 ms |
5760 KB |
Output is correct |
17 |
Correct |
6 ms |
5888 KB |
Output is correct |
18 |
Correct |
9 ms |
5760 KB |
Output is correct |
19 |
Correct |
7 ms |
5760 KB |
Output is correct |
20 |
Correct |
7 ms |
5760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
8320 KB |
Output is correct |
2 |
Correct |
10 ms |
8320 KB |
Output is correct |
3 |
Correct |
10 ms |
8320 KB |
Output is correct |
4 |
Correct |
11 ms |
8320 KB |
Output is correct |
5 |
Correct |
12 ms |
8320 KB |
Output is correct |
6 |
Correct |
14 ms |
8320 KB |
Output is correct |
7 |
Correct |
13 ms |
8320 KB |
Output is correct |
8 |
Correct |
12 ms |
8320 KB |
Output is correct |
9 |
Correct |
11 ms |
8320 KB |
Output is correct |
10 |
Correct |
11 ms |
8320 KB |
Output is correct |
11 |
Correct |
11 ms |
8320 KB |
Output is correct |
12 |
Correct |
11 ms |
8320 KB |
Output is correct |
13 |
Correct |
11 ms |
8448 KB |
Output is correct |
14 |
Correct |
13 ms |
8320 KB |
Output is correct |
15 |
Correct |
10 ms |
8320 KB |
Output is correct |
16 |
Correct |
12 ms |
5760 KB |
Output is correct |
17 |
Correct |
6 ms |
5888 KB |
Output is correct |
18 |
Correct |
9 ms |
5760 KB |
Output is correct |
19 |
Correct |
7 ms |
5760 KB |
Output is correct |
20 |
Correct |
7 ms |
5760 KB |
Output is correct |
21 |
Incorrect |
11 ms |
8448 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
8320 KB |
Output is correct |
2 |
Correct |
10 ms |
8320 KB |
Output is correct |
3 |
Correct |
10 ms |
8320 KB |
Output is correct |
4 |
Correct |
11 ms |
8320 KB |
Output is correct |
5 |
Correct |
12 ms |
8320 KB |
Output is correct |
6 |
Correct |
14 ms |
8320 KB |
Output is correct |
7 |
Correct |
13 ms |
8320 KB |
Output is correct |
8 |
Correct |
12 ms |
8320 KB |
Output is correct |
9 |
Correct |
11 ms |
8320 KB |
Output is correct |
10 |
Correct |
11 ms |
8320 KB |
Output is correct |
11 |
Correct |
11 ms |
8320 KB |
Output is correct |
12 |
Correct |
11 ms |
8320 KB |
Output is correct |
13 |
Correct |
11 ms |
8448 KB |
Output is correct |
14 |
Correct |
13 ms |
8320 KB |
Output is correct |
15 |
Correct |
10 ms |
8320 KB |
Output is correct |
16 |
Correct |
12 ms |
5760 KB |
Output is correct |
17 |
Correct |
6 ms |
5888 KB |
Output is correct |
18 |
Correct |
9 ms |
5760 KB |
Output is correct |
19 |
Correct |
7 ms |
5760 KB |
Output is correct |
20 |
Correct |
7 ms |
5760 KB |
Output is correct |
21 |
Incorrect |
11 ms |
8448 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |