# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
20365 |
2017-02-07T08:42:08 Z |
|
초음속철도 (OJUZ11_rail) |
C++ |
|
614 ms |
250228 KB |
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MOD (ll)(1e9+7)
int N,M;
const int MAX_M = 5010;
ll dp[MAX_M][MAX_M];
ll dp2[200010];
struct pt{
int s,e;
pt(){}
pt(int s_,int e_):s(s_),e(e_){}
bool operator<(const pt& r)const{
return s!=r.s?s<r.s:e<r.e;
}
}a[MAX_M];
ll pw(ll x,ll y){
ll ret=1;
while(y){
if(y&1)ret=(ret*x)%MOD;
x=(x*x)%MOD;
y>>=1;
}
return ret;
}
ll f(int x,int lim){
if(x>M)return a[lim].e==N;
if(a[lim].e<a[x].s)return 0;
ll& ret=dp[x][lim];
if(~ret)return ret;
ret=(f(x+1,lim)+f(x+1,a[lim].e<a[x].e?x:lim))%MOD;
return ret;
}
ll f2(int x){
if(x==N)return 1;
ll& ret=dp2[x];
if(~ret)return ret;
ret=0;
int L=lower_bound(a+1,a+M+1,pt(x,0))-a;
int R=lower_bound(a+1,a+M+1,pt(x+1,0))-a;
for(int i=L;i<R;i++){
ret+=f2(a[i].e);
ret%=MOD;
}
return ret;
}
int cmp[MAX_M*2],sz;
int main(){
memset(dp,-1,sizeof(dp));
memset(dp2,-1,sizeof(dp2));
scanf("%d%d",&N,&M);
a[0]=pt{1,1};
cmp[sz++]=1;cmp[sz++]=N;
for(int i=1,x,y;i<=M;i++){
scanf("%d%d",&x,&y);
a[i]=pt(x,y);
cmp[sz++]=x;
cmp[sz++]=y;
}
sort(cmp,cmp+sz);
sz=unique(cmp,cmp+sz)-cmp;
for(int i=0;i<=M;i++){
a[i].s=lower_bound(cmp,cmp+sz,a[i].s)-cmp;
a[i].e=lower_bound(cmp,cmp+sz,a[i].e)-cmp;
}
N=lower_bound(cmp,cmp+sz,N)-cmp;
sort(a+1,a+M+1);
if(M>=MAX_M){
printf("%lld\n",f2(0));
}
printf("%lld\n",f(1,0));
return 0;
}
Compilation message
rail.cpp: In function 'int main()':
rail.cpp:65:9: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
a[0]=pt{1,1};
^
rail.cpp:63:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&N,&M);
^
rail.cpp:68:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&x,&y);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
198232 KB |
Output is correct |
2 |
Correct |
141 ms |
198256 KB |
Output is correct |
3 |
Correct |
125 ms |
198356 KB |
Output is correct |
4 |
Correct |
126 ms |
198356 KB |
Output is correct |
5 |
Correct |
126 ms |
198396 KB |
Output is correct |
6 |
Correct |
125 ms |
198396 KB |
Output is correct |
7 |
Correct |
124 ms |
198396 KB |
Output is correct |
8 |
Correct |
138 ms |
198396 KB |
Output is correct |
9 |
Correct |
128 ms |
198396 KB |
Output is correct |
10 |
Correct |
129 ms |
198396 KB |
Output is correct |
11 |
Correct |
125 ms |
198396 KB |
Output is correct |
12 |
Correct |
126 ms |
198396 KB |
Output is correct |
13 |
Correct |
129 ms |
198396 KB |
Output is correct |
14 |
Correct |
127 ms |
198396 KB |
Output is correct |
15 |
Correct |
128 ms |
198396 KB |
Output is correct |
16 |
Correct |
126 ms |
198396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
198232 KB |
Output is correct |
2 |
Correct |
141 ms |
198256 KB |
Output is correct |
3 |
Correct |
125 ms |
198356 KB |
Output is correct |
4 |
Correct |
126 ms |
198356 KB |
Output is correct |
5 |
Correct |
126 ms |
198396 KB |
Output is correct |
6 |
Correct |
125 ms |
198396 KB |
Output is correct |
7 |
Correct |
124 ms |
198396 KB |
Output is correct |
8 |
Correct |
138 ms |
198396 KB |
Output is correct |
9 |
Correct |
128 ms |
198396 KB |
Output is correct |
10 |
Correct |
129 ms |
198396 KB |
Output is correct |
11 |
Correct |
125 ms |
198396 KB |
Output is correct |
12 |
Correct |
126 ms |
198396 KB |
Output is correct |
13 |
Correct |
129 ms |
198396 KB |
Output is correct |
14 |
Correct |
127 ms |
198396 KB |
Output is correct |
15 |
Correct |
128 ms |
198396 KB |
Output is correct |
16 |
Correct |
126 ms |
198396 KB |
Output is correct |
17 |
Correct |
130 ms |
198396 KB |
Output is correct |
18 |
Correct |
127 ms |
198396 KB |
Output is correct |
19 |
Correct |
124 ms |
198396 KB |
Output is correct |
20 |
Correct |
133 ms |
198400 KB |
Output is correct |
21 |
Correct |
130 ms |
198400 KB |
Output is correct |
22 |
Correct |
128 ms |
198400 KB |
Output is correct |
23 |
Correct |
126 ms |
198400 KB |
Output is correct |
24 |
Correct |
126 ms |
198400 KB |
Output is correct |
25 |
Correct |
124 ms |
198400 KB |
Output is correct |
26 |
Correct |
126 ms |
198400 KB |
Output is correct |
27 |
Correct |
133 ms |
198400 KB |
Output is correct |
28 |
Correct |
127 ms |
198400 KB |
Output is correct |
29 |
Correct |
126 ms |
198400 KB |
Output is correct |
30 |
Correct |
126 ms |
198420 KB |
Output is correct |
31 |
Correct |
128 ms |
198420 KB |
Output is correct |
32 |
Correct |
128 ms |
198420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
198420 KB |
Output is correct |
2 |
Correct |
126 ms |
198420 KB |
Output is correct |
3 |
Correct |
128 ms |
198420 KB |
Output is correct |
4 |
Correct |
480 ms |
198780 KB |
Output is correct |
5 |
Incorrect |
228 ms |
198780 KB |
Output isn't correct |
6 |
Incorrect |
261 ms |
198780 KB |
Output isn't correct |
7 |
Incorrect |
262 ms |
198780 KB |
Output isn't correct |
8 |
Correct |
127 ms |
198780 KB |
Output is correct |
9 |
Incorrect |
246 ms |
198780 KB |
Output isn't correct |
10 |
Incorrect |
276 ms |
198780 KB |
Output isn't correct |
11 |
Incorrect |
174 ms |
198784 KB |
Output isn't correct |
12 |
Incorrect |
271 ms |
198784 KB |
Output isn't correct |
13 |
Incorrect |
275 ms |
198784 KB |
Output isn't correct |
14 |
Incorrect |
194 ms |
198784 KB |
Output isn't correct |
15 |
Incorrect |
203 ms |
198956 KB |
Output isn't correct |
16 |
Incorrect |
264 ms |
198956 KB |
Output isn't correct |
17 |
Incorrect |
260 ms |
198956 KB |
Output isn't correct |
18 |
Incorrect |
266 ms |
198956 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
198232 KB |
Output is correct |
2 |
Correct |
141 ms |
198256 KB |
Output is correct |
3 |
Correct |
125 ms |
198356 KB |
Output is correct |
4 |
Correct |
126 ms |
198356 KB |
Output is correct |
5 |
Correct |
126 ms |
198396 KB |
Output is correct |
6 |
Correct |
125 ms |
198396 KB |
Output is correct |
7 |
Correct |
124 ms |
198396 KB |
Output is correct |
8 |
Correct |
138 ms |
198396 KB |
Output is correct |
9 |
Correct |
128 ms |
198396 KB |
Output is correct |
10 |
Correct |
129 ms |
198396 KB |
Output is correct |
11 |
Correct |
125 ms |
198396 KB |
Output is correct |
12 |
Correct |
126 ms |
198396 KB |
Output is correct |
13 |
Correct |
129 ms |
198396 KB |
Output is correct |
14 |
Correct |
127 ms |
198396 KB |
Output is correct |
15 |
Correct |
128 ms |
198396 KB |
Output is correct |
16 |
Correct |
126 ms |
198396 KB |
Output is correct |
17 |
Correct |
130 ms |
198396 KB |
Output is correct |
18 |
Correct |
127 ms |
198396 KB |
Output is correct |
19 |
Correct |
124 ms |
198396 KB |
Output is correct |
20 |
Correct |
133 ms |
198400 KB |
Output is correct |
21 |
Correct |
130 ms |
198400 KB |
Output is correct |
22 |
Correct |
128 ms |
198400 KB |
Output is correct |
23 |
Correct |
126 ms |
198400 KB |
Output is correct |
24 |
Correct |
126 ms |
198400 KB |
Output is correct |
25 |
Correct |
124 ms |
198400 KB |
Output is correct |
26 |
Correct |
126 ms |
198400 KB |
Output is correct |
27 |
Correct |
133 ms |
198400 KB |
Output is correct |
28 |
Correct |
127 ms |
198400 KB |
Output is correct |
29 |
Correct |
126 ms |
198400 KB |
Output is correct |
30 |
Correct |
126 ms |
198420 KB |
Output is correct |
31 |
Correct |
128 ms |
198420 KB |
Output is correct |
32 |
Correct |
128 ms |
198420 KB |
Output is correct |
33 |
Correct |
400 ms |
198956 KB |
Output is correct |
34 |
Correct |
409 ms |
198956 KB |
Output is correct |
35 |
Correct |
388 ms |
198956 KB |
Output is correct |
36 |
Correct |
607 ms |
198956 KB |
Output is correct |
37 |
Correct |
140 ms |
198956 KB |
Output is correct |
38 |
Correct |
287 ms |
198956 KB |
Output is correct |
39 |
Correct |
129 ms |
198956 KB |
Output is correct |
40 |
Correct |
589 ms |
198956 KB |
Output is correct |
41 |
Correct |
595 ms |
198956 KB |
Output is correct |
42 |
Correct |
529 ms |
198956 KB |
Output is correct |
43 |
Correct |
470 ms |
198956 KB |
Output is correct |
44 |
Correct |
563 ms |
198956 KB |
Output is correct |
45 |
Correct |
574 ms |
198956 KB |
Output is correct |
46 |
Correct |
589 ms |
198956 KB |
Output is correct |
47 |
Correct |
614 ms |
198956 KB |
Output is correct |
48 |
Correct |
139 ms |
198956 KB |
Output is correct |
49 |
Correct |
129 ms |
198956 KB |
Output is correct |
50 |
Correct |
253 ms |
198956 KB |
Output is correct |
51 |
Correct |
133 ms |
198956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
198232 KB |
Output is correct |
2 |
Correct |
141 ms |
198256 KB |
Output is correct |
3 |
Correct |
125 ms |
198356 KB |
Output is correct |
4 |
Correct |
126 ms |
198356 KB |
Output is correct |
5 |
Correct |
126 ms |
198396 KB |
Output is correct |
6 |
Correct |
125 ms |
198396 KB |
Output is correct |
7 |
Correct |
124 ms |
198396 KB |
Output is correct |
8 |
Correct |
138 ms |
198396 KB |
Output is correct |
9 |
Correct |
128 ms |
198396 KB |
Output is correct |
10 |
Correct |
129 ms |
198396 KB |
Output is correct |
11 |
Correct |
125 ms |
198396 KB |
Output is correct |
12 |
Correct |
126 ms |
198396 KB |
Output is correct |
13 |
Correct |
129 ms |
198396 KB |
Output is correct |
14 |
Correct |
127 ms |
198396 KB |
Output is correct |
15 |
Correct |
128 ms |
198396 KB |
Output is correct |
16 |
Correct |
126 ms |
198396 KB |
Output is correct |
17 |
Correct |
130 ms |
198396 KB |
Output is correct |
18 |
Correct |
127 ms |
198396 KB |
Output is correct |
19 |
Correct |
124 ms |
198396 KB |
Output is correct |
20 |
Correct |
133 ms |
198400 KB |
Output is correct |
21 |
Correct |
130 ms |
198400 KB |
Output is correct |
22 |
Correct |
128 ms |
198400 KB |
Output is correct |
23 |
Correct |
126 ms |
198400 KB |
Output is correct |
24 |
Correct |
126 ms |
198400 KB |
Output is correct |
25 |
Correct |
124 ms |
198400 KB |
Output is correct |
26 |
Correct |
126 ms |
198400 KB |
Output is correct |
27 |
Correct |
133 ms |
198400 KB |
Output is correct |
28 |
Correct |
127 ms |
198400 KB |
Output is correct |
29 |
Correct |
126 ms |
198400 KB |
Output is correct |
30 |
Correct |
126 ms |
198420 KB |
Output is correct |
31 |
Correct |
128 ms |
198420 KB |
Output is correct |
32 |
Correct |
128 ms |
198420 KB |
Output is correct |
33 |
Correct |
126 ms |
198420 KB |
Output is correct |
34 |
Correct |
126 ms |
198420 KB |
Output is correct |
35 |
Correct |
128 ms |
198420 KB |
Output is correct |
36 |
Correct |
480 ms |
198780 KB |
Output is correct |
37 |
Incorrect |
228 ms |
198780 KB |
Output isn't correct |
38 |
Incorrect |
261 ms |
198780 KB |
Output isn't correct |
39 |
Incorrect |
262 ms |
198780 KB |
Output isn't correct |
40 |
Correct |
127 ms |
198780 KB |
Output is correct |
41 |
Incorrect |
246 ms |
198780 KB |
Output isn't correct |
42 |
Incorrect |
276 ms |
198780 KB |
Output isn't correct |
43 |
Incorrect |
174 ms |
198784 KB |
Output isn't correct |
44 |
Incorrect |
271 ms |
198784 KB |
Output isn't correct |
45 |
Incorrect |
275 ms |
198784 KB |
Output isn't correct |
46 |
Incorrect |
194 ms |
198784 KB |
Output isn't correct |
47 |
Incorrect |
203 ms |
198956 KB |
Output isn't correct |
48 |
Incorrect |
264 ms |
198956 KB |
Output isn't correct |
49 |
Incorrect |
260 ms |
198956 KB |
Output isn't correct |
50 |
Incorrect |
266 ms |
198956 KB |
Output isn't correct |
51 |
Correct |
400 ms |
198956 KB |
Output is correct |
52 |
Correct |
409 ms |
198956 KB |
Output is correct |
53 |
Correct |
388 ms |
198956 KB |
Output is correct |
54 |
Correct |
607 ms |
198956 KB |
Output is correct |
55 |
Correct |
140 ms |
198956 KB |
Output is correct |
56 |
Correct |
287 ms |
198956 KB |
Output is correct |
57 |
Correct |
129 ms |
198956 KB |
Output is correct |
58 |
Correct |
589 ms |
198956 KB |
Output is correct |
59 |
Correct |
595 ms |
198956 KB |
Output is correct |
60 |
Correct |
529 ms |
198956 KB |
Output is correct |
61 |
Correct |
470 ms |
198956 KB |
Output is correct |
62 |
Correct |
563 ms |
198956 KB |
Output is correct |
63 |
Correct |
574 ms |
198956 KB |
Output is correct |
64 |
Correct |
589 ms |
198956 KB |
Output is correct |
65 |
Correct |
614 ms |
198956 KB |
Output is correct |
66 |
Correct |
139 ms |
198956 KB |
Output is correct |
67 |
Correct |
129 ms |
198956 KB |
Output is correct |
68 |
Correct |
253 ms |
198956 KB |
Output is correct |
69 |
Correct |
133 ms |
198956 KB |
Output is correct |
70 |
Incorrect |
267 ms |
198956 KB |
Output isn't correct |
71 |
Incorrect |
222 ms |
198956 KB |
Output isn't correct |
72 |
Runtime error |
270 ms |
250092 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
73 |
Incorrect |
176 ms |
250124 KB |
Output isn't correct |
74 |
Incorrect |
236 ms |
250188 KB |
Output isn't correct |
75 |
Incorrect |
266 ms |
250188 KB |
Output isn't correct |
76 |
Correct |
506 ms |
250188 KB |
Output is correct |
77 |
Runtime error |
458 ms |
250228 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
78 |
Incorrect |
180 ms |
250228 KB |
Output isn't correct |
79 |
Runtime error |
314 ms |
250228 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
80 |
Incorrect |
252 ms |
250228 KB |
Output isn't correct |
81 |
Incorrect |
252 ms |
250228 KB |
Output isn't correct |
82 |
Incorrect |
210 ms |
250228 KB |
Output isn't correct |
83 |
Incorrect |
232 ms |
250228 KB |
Output isn't correct |
84 |
Incorrect |
272 ms |
250228 KB |
Output isn't correct |
85 |
Incorrect |
272 ms |
250228 KB |
Output isn't correct |
86 |
Incorrect |
275 ms |
250228 KB |
Output isn't correct |
87 |
Incorrect |
285 ms |
250228 KB |
Output isn't correct |
88 |
Incorrect |
273 ms |
250228 KB |
Output isn't correct |
89 |
Incorrect |
261 ms |
250228 KB |
Output isn't correct |
90 |
Incorrect |
260 ms |
250228 KB |
Output isn't correct |