Submission #20345

# Submission time Handle Problem Language Result Execution time Memory
20345 2017-02-07T06:49:54 Z 초음속철도 (OJUZ11_rail) C++
45 / 100
617 ms 197260 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];

struct pt{
	int s,e;
	bool operator<(const pt& r)const{
		return s!=r.s?s<r.s:e<r.e;
	}
}a[MAX_M];

ll f(int x,int lim){
	if(x>M)return a[lim].e==N;
	ll& ret=dp[x][lim];
	if(~ret)return ret;
	if(a[lim].e<a[x].s)return 0;

	return ret=(f(x+1,lim)+f(x+1,a[lim].e<a[x].e?x:lim))%MOD;
}

int main(){

	memset(dp,-1,sizeof(dp));

	scanf("%d%d",&N,&M);

	a[0]=pt{1,1};
	for(int i=1,x,y;i<=M;i++){
		scanf("%d%d",&x,&y);
		a[i]=pt{x,y};
	}

	sort(a+1,a+M+1);


	printf("%lld\n",f(1,0));

	return 0;
}

Compilation message

rail.cpp: In function 'int main()':
rail.cpp:35:9: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  a[0]=pt{1,1};
         ^
rail.cpp:38:10: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   a[i]=pt{x,y};
          ^
rail.cpp:33: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:37: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 124 ms 196756 KB Output is correct
2 Correct 129 ms 196756 KB Output is correct
3 Correct 135 ms 196756 KB Output is correct
4 Correct 129 ms 196756 KB Output is correct
5 Correct 128 ms 196756 KB Output is correct
6 Correct 124 ms 196756 KB Output is correct
7 Correct 135 ms 196756 KB Output is correct
8 Correct 129 ms 196756 KB Output is correct
9 Correct 132 ms 196756 KB Output is correct
10 Correct 126 ms 196756 KB Output is correct
11 Correct 124 ms 196756 KB Output is correct
12 Correct 129 ms 196756 KB Output is correct
13 Correct 129 ms 196756 KB Output is correct
14 Correct 126 ms 196756 KB Output is correct
15 Correct 126 ms 196756 KB Output is correct
16 Correct 125 ms 196756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 196756 KB Output is correct
2 Correct 129 ms 196756 KB Output is correct
3 Correct 135 ms 196756 KB Output is correct
4 Correct 129 ms 196756 KB Output is correct
5 Correct 128 ms 196756 KB Output is correct
6 Correct 124 ms 196756 KB Output is correct
7 Correct 135 ms 196756 KB Output is correct
8 Correct 129 ms 196756 KB Output is correct
9 Correct 132 ms 196756 KB Output is correct
10 Correct 126 ms 196756 KB Output is correct
11 Correct 124 ms 196756 KB Output is correct
12 Correct 129 ms 196756 KB Output is correct
13 Correct 129 ms 196756 KB Output is correct
14 Correct 126 ms 196756 KB Output is correct
15 Correct 126 ms 196756 KB Output is correct
16 Correct 125 ms 196756 KB Output is correct
17 Correct 125 ms 196816 KB Output is correct
18 Correct 127 ms 196816 KB Output is correct
19 Correct 127 ms 196816 KB Output is correct
20 Correct 126 ms 196816 KB Output is correct
21 Correct 127 ms 196816 KB Output is correct
22 Correct 133 ms 196816 KB Output is correct
23 Correct 129 ms 196816 KB Output is correct
24 Correct 132 ms 196816 KB Output is correct
25 Correct 144 ms 196816 KB Output is correct
26 Correct 143 ms 196816 KB Output is correct
27 Correct 132 ms 196816 KB Output is correct
28 Correct 126 ms 196816 KB Output is correct
29 Correct 127 ms 196816 KB Output is correct
30 Correct 128 ms 196816 KB Output is correct
31 Correct 130 ms 196816 KB Output is correct
32 Correct 127 ms 196816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 125 ms 196816 KB Output is correct
2 Correct 127 ms 196816 KB Output is correct
3 Correct 124 ms 196852 KB Output is correct
4 Correct 462 ms 197260 KB Output is correct
5 Incorrect 200 ms 197260 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 196756 KB Output is correct
2 Correct 129 ms 196756 KB Output is correct
3 Correct 135 ms 196756 KB Output is correct
4 Correct 129 ms 196756 KB Output is correct
5 Correct 128 ms 196756 KB Output is correct
6 Correct 124 ms 196756 KB Output is correct
7 Correct 135 ms 196756 KB Output is correct
8 Correct 129 ms 196756 KB Output is correct
9 Correct 132 ms 196756 KB Output is correct
10 Correct 126 ms 196756 KB Output is correct
11 Correct 124 ms 196756 KB Output is correct
12 Correct 129 ms 196756 KB Output is correct
13 Correct 129 ms 196756 KB Output is correct
14 Correct 126 ms 196756 KB Output is correct
15 Correct 126 ms 196756 KB Output is correct
16 Correct 125 ms 196756 KB Output is correct
17 Correct 125 ms 196816 KB Output is correct
18 Correct 127 ms 196816 KB Output is correct
19 Correct 127 ms 196816 KB Output is correct
20 Correct 126 ms 196816 KB Output is correct
21 Correct 127 ms 196816 KB Output is correct
22 Correct 133 ms 196816 KB Output is correct
23 Correct 129 ms 196816 KB Output is correct
24 Correct 132 ms 196816 KB Output is correct
25 Correct 144 ms 196816 KB Output is correct
26 Correct 143 ms 196816 KB Output is correct
27 Correct 132 ms 196816 KB Output is correct
28 Correct 126 ms 196816 KB Output is correct
29 Correct 127 ms 196816 KB Output is correct
30 Correct 128 ms 196816 KB Output is correct
31 Correct 130 ms 196816 KB Output is correct
32 Correct 127 ms 196816 KB Output is correct
33 Correct 393 ms 197260 KB Output is correct
34 Correct 419 ms 197260 KB Output is correct
35 Correct 435 ms 197260 KB Output is correct
36 Correct 617 ms 197260 KB Output is correct
37 Correct 127 ms 197260 KB Output is correct
38 Correct 298 ms 197260 KB Output is correct
39 Correct 125 ms 197260 KB Output is correct
40 Correct 589 ms 197260 KB Output is correct
41 Correct 572 ms 197260 KB Output is correct
42 Correct 555 ms 197260 KB Output is correct
43 Correct 470 ms 197260 KB Output is correct
44 Correct 529 ms 197260 KB Output is correct
45 Correct 595 ms 197260 KB Output is correct
46 Correct 567 ms 197260 KB Output is correct
47 Correct 570 ms 197260 KB Output is correct
48 Correct 134 ms 197260 KB Output is correct
49 Correct 129 ms 197260 KB Output is correct
50 Correct 266 ms 197260 KB Output is correct
51 Correct 127 ms 197260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 196756 KB Output is correct
2 Correct 129 ms 196756 KB Output is correct
3 Correct 135 ms 196756 KB Output is correct
4 Correct 129 ms 196756 KB Output is correct
5 Correct 128 ms 196756 KB Output is correct
6 Correct 124 ms 196756 KB Output is correct
7 Correct 135 ms 196756 KB Output is correct
8 Correct 129 ms 196756 KB Output is correct
9 Correct 132 ms 196756 KB Output is correct
10 Correct 126 ms 196756 KB Output is correct
11 Correct 124 ms 196756 KB Output is correct
12 Correct 129 ms 196756 KB Output is correct
13 Correct 129 ms 196756 KB Output is correct
14 Correct 126 ms 196756 KB Output is correct
15 Correct 126 ms 196756 KB Output is correct
16 Correct 125 ms 196756 KB Output is correct
17 Correct 125 ms 196816 KB Output is correct
18 Correct 127 ms 196816 KB Output is correct
19 Correct 127 ms 196816 KB Output is correct
20 Correct 126 ms 196816 KB Output is correct
21 Correct 127 ms 196816 KB Output is correct
22 Correct 133 ms 196816 KB Output is correct
23 Correct 129 ms 196816 KB Output is correct
24 Correct 132 ms 196816 KB Output is correct
25 Correct 144 ms 196816 KB Output is correct
26 Correct 143 ms 196816 KB Output is correct
27 Correct 132 ms 196816 KB Output is correct
28 Correct 126 ms 196816 KB Output is correct
29 Correct 127 ms 196816 KB Output is correct
30 Correct 128 ms 196816 KB Output is correct
31 Correct 130 ms 196816 KB Output is correct
32 Correct 127 ms 196816 KB Output is correct
33 Correct 125 ms 196816 KB Output is correct
34 Correct 127 ms 196816 KB Output is correct
35 Correct 124 ms 196852 KB Output is correct
36 Correct 462 ms 197260 KB Output is correct
37 Incorrect 200 ms 197260 KB -