답안 #66243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66243 2018-08-10T05:31:39 Z 노영훈(#1886) 초음속철도 (OJUZ11_rail) C++11
45 / 100
395 ms 197952 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=5010, MOD=1e9+7;

int pw(int e){
	if(e==0) return 1;
	ll t=pw(e/2); t=t*t%MOD;
	return (e%2==0 ? t : t*2%MOD);
}

int n, m, lim;
struct rail{
	int s, e;
	void scan(){ cin>>s>>e; }
} R[MX];

vector<int> P[2*MX];
int D[MX][2*MX];
int solve(){
	for(int i=1; i<=n; i++){
		P[R[i].s].push_back(R[i].e);
	}
//	for(int i=1; i<=lim; i++) sort(P[i].begin(), P[i].end());

	D[0][1]=1;

	for(int s=1, pos=0; s<=lim; s++){
		for(int e:P[s]){
			pos++;
			for(int x=1; x<=lim; x++)
				D[pos][x]=D[pos-1][x];
			for(int x=s; x<=lim; x++)
				D[pos][max(x,e)] = (D[pos][max(x,e)] + D[pos-1][x])%MOD;
		}
	}
//	for(int i=1; i<=n; i++, cout<<'\n') for(int j=1; j<=lim; j++) cout<<D[i][j]<<' ';

	return D[n][lim];
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>m>>n;
	vector<int> X={1,m};
	for(int i=1; i<=n; i++){
		R[i].scan();
		X.push_back(R[i].s);
		X.push_back(R[i].e);
	}
	sort(X.begin(), X.end());
	lim=unique(X.begin(), X.end())-X.begin();
	X.resize(lim);
	for(int i=1; i<=n; i++){
		R[i].s=lower_bound(X.begin(), X.end(), R[i].s)-X.begin()+1;
		R[i].e=lower_bound(X.begin(), X.end(), R[i].e)-X.begin()+1;
	}

	cout<<solve()<<'\n';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 2 ms 744 KB Output is correct
3 Correct 4 ms 808 KB Output is correct
4 Correct 4 ms 808 KB Output is correct
5 Correct 3 ms 808 KB Output is correct
6 Correct 4 ms 808 KB Output is correct
7 Correct 3 ms 932 KB Output is correct
8 Correct 3 ms 932 KB Output is correct
9 Correct 3 ms 932 KB Output is correct
10 Correct 2 ms 932 KB Output is correct
11 Correct 3 ms 932 KB Output is correct
12 Correct 3 ms 932 KB Output is correct
13 Correct 3 ms 932 KB Output is correct
14 Correct 3 ms 932 KB Output is correct
15 Correct 3 ms 932 KB Output is correct
16 Correct 2 ms 932 KB Output is correct
17 Correct 2 ms 932 KB Output is correct
18 Correct 4 ms 932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 2 ms 744 KB Output is correct
3 Correct 4 ms 808 KB Output is correct
4 Correct 4 ms 808 KB Output is correct
5 Correct 3 ms 808 KB Output is correct
6 Correct 4 ms 808 KB Output is correct
7 Correct 3 ms 932 KB Output is correct
8 Correct 3 ms 932 KB Output is correct
9 Correct 3 ms 932 KB Output is correct
10 Correct 2 ms 932 KB Output is correct
11 Correct 3 ms 932 KB Output is correct
12 Correct 3 ms 932 KB Output is correct
13 Correct 3 ms 932 KB Output is correct
14 Correct 3 ms 932 KB Output is correct
15 Correct 3 ms 932 KB Output is correct
16 Correct 2 ms 932 KB Output is correct
17 Correct 2 ms 932 KB Output is correct
18 Correct 4 ms 932 KB Output is correct
19 Correct 3 ms 932 KB Output is correct
20 Correct 2 ms 932 KB Output is correct
21 Correct 2 ms 932 KB Output is correct
22 Correct 3 ms 932 KB Output is correct
23 Correct 3 ms 932 KB Output is correct
24 Correct 3 ms 932 KB Output is correct
25 Correct 2 ms 932 KB Output is correct
26 Correct 3 ms 932 KB Output is correct
27 Correct 3 ms 932 KB Output is correct
28 Correct 3 ms 932 KB Output is correct
29 Correct 3 ms 932 KB Output is correct
30 Correct 3 ms 932 KB Output is correct
31 Correct 3 ms 932 KB Output is correct
32 Correct 2 ms 932 KB Output is correct
33 Correct 3 ms 932 KB Output is correct
34 Correct 2 ms 932 KB Output is correct
35 Correct 4 ms 932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 932 KB Output is correct
2 Correct 3 ms 932 KB Output is correct
3 Correct 2 ms 932 KB Output is correct
4 Correct 80 ms 47844 KB Output is correct
5 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Correct 2 ms 47844 KB Output is correct
9 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Incorrect 4 ms 47844 KB Output isn't correct
15 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Incorrect 4 ms 47844 KB Output isn't correct
17 Runtime error 11 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 13 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 2 ms 744 KB Output is correct
3 Correct 4 ms 808 KB Output is correct
4 Correct 4 ms 808 KB Output is correct
5 Correct 3 ms 808 KB Output is correct
6 Correct 4 ms 808 KB Output is correct
7 Correct 3 ms 932 KB Output is correct
8 Correct 3 ms 932 KB Output is correct
9 Correct 3 ms 932 KB Output is correct
10 Correct 2 ms 932 KB Output is correct
11 Correct 3 ms 932 KB Output is correct
12 Correct 3 ms 932 KB Output is correct
13 Correct 3 ms 932 KB Output is correct
14 Correct 3 ms 932 KB Output is correct
15 Correct 3 ms 932 KB Output is correct
16 Correct 2 ms 932 KB Output is correct
17 Correct 2 ms 932 KB Output is correct
18 Correct 4 ms 932 KB Output is correct
19 Correct 3 ms 932 KB Output is correct
20 Correct 2 ms 932 KB Output is correct
21 Correct 2 ms 932 KB Output is correct
22 Correct 3 ms 932 KB Output is correct
23 Correct 3 ms 932 KB Output is correct
24 Correct 3 ms 932 KB Output is correct
25 Correct 2 ms 932 KB Output is correct
26 Correct 3 ms 932 KB Output is correct
27 Correct 3 ms 932 KB Output is correct
28 Correct 3 ms 932 KB Output is correct
29 Correct 3 ms 932 KB Output is correct
30 Correct 3 ms 932 KB Output is correct
31 Correct 3 ms 932 KB Output is correct
32 Correct 2 ms 932 KB Output is correct
33 Correct 3 ms 932 KB Output is correct
34 Correct 2 ms 932 KB Output is correct
35 Correct 4 ms 932 KB Output is correct
36 Correct 362 ms 197928 KB Output is correct
37 Correct 261 ms 197928 KB Output is correct
38 Correct 93 ms 197928 KB Output is correct
39 Correct 17 ms 197928 KB Output is correct
40 Correct 140 ms 197928 KB Output is correct
41 Correct 317 ms 197928 KB Output is correct
42 Correct 347 ms 197952 KB Output is correct
43 Correct 2 ms 197952 KB Output is correct
44 Correct 284 ms 197952 KB Output is correct
45 Correct 17 ms 197952 KB Output is correct
46 Correct 222 ms 197952 KB Output is correct
47 Correct 222 ms 197952 KB Output is correct
48 Correct 197 ms 197952 KB Output is correct
49 Correct 29 ms 197952 KB Output is correct
50 Correct 22 ms 197952 KB Output is correct
51 Correct 21 ms 197952 KB Output is correct
52 Correct 21 ms 197952 KB Output is correct
53 Correct 306 ms 197952 KB Output is correct
54 Correct 89 ms 197952 KB Output is correct
55 Correct 395 ms 197952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 2 ms 744 KB Output is correct
3 Correct 4 ms 808 KB Output is correct
4 Correct 4 ms 808 KB Output is correct
5 Correct 3 ms 808 KB Output is correct
6 Correct 4 ms 808 KB Output is correct
7 Correct 3 ms 932 KB Output is correct
8 Correct 3 ms 932 KB Output is correct
9 Correct 3 ms 932 KB Output is correct
10 Correct 2 ms 932 KB Output is correct
11 Correct 3 ms 932 KB Output is correct
12 Correct 3 ms 932 KB Output is correct
13 Correct 3 ms 932 KB Output is correct
14 Correct 3 ms 932 KB Output is correct
15 Correct 3 ms 932 KB Output is correct
16 Correct 2 ms 932 KB Output is correct
17 Correct 2 ms 932 KB Output is correct
18 Correct 4 ms 932 KB Output is correct
19 Correct 3 ms 932 KB Output is correct
20 Correct 2 ms 932 KB Output is correct
21 Correct 2 ms 932 KB Output is correct
22 Correct 3 ms 932 KB Output is correct
23 Correct 3 ms 932 KB Output is correct
24 Correct 3 ms 932 KB Output is correct
25 Correct 2 ms 932 KB Output is correct
26 Correct 3 ms 932 KB Output is correct
27 Correct 3 ms 932 KB Output is correct
28 Correct 3 ms 932 KB Output is correct
29 Correct 3 ms 932 KB Output is correct
30 Correct 3 ms 932 KB Output is correct
31 Correct 3 ms 932 KB Output is correct
32 Correct 2 ms 932 KB Output is correct
33 Correct 3 ms 932 KB Output is correct
34 Correct 2 ms 932 KB Output is correct
35 Correct 4 ms 932 KB Output is correct
36 Correct 3 ms 932 KB Output is correct
37 Correct 3 ms 932 KB Output is correct
38 Correct 2 ms 932 KB Output is correct
39 Correct 80 ms 47844 KB Output is correct
40 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
43 Correct 2 ms 47844 KB Output is correct
44 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
46 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Runtime error 9 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Incorrect 4 ms 47844 KB Output isn't correct
50 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
51 Incorrect 4 ms 47844 KB Output isn't correct
52 Runtime error 11 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Runtime error 13 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Runtime error 10 ms 47844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Correct 362 ms 197928 KB Output is correct
56 Correct 261 ms 197928 KB Output is correct
57 Correct 93 ms 197928 KB Output is correct
58 Correct 17 ms 197928 KB Output is correct
59 Correct 140 ms 197928 KB Output is correct
60 Correct 317 ms 197928 KB Output is correct
61 Correct 347 ms 197952 KB Output is correct
62 Correct 2 ms 197952 KB Output is correct
63 Correct 284 ms 197952 KB Output is correct
64 Correct 17 ms 197952 KB Output is correct
65 Correct 222 ms 197952 KB Output is correct
66 Correct 222 ms 197952 KB Output is correct
67 Correct 197 ms 197952 KB Output is correct
68 Correct 29 ms 197952 KB Output is correct
69 Correct 22 ms 197952 KB Output is correct
70 Correct 21 ms 197952 KB Output is correct
71 Correct 21 ms 197952 KB Output is correct
72 Correct 306 ms 197952 KB Output is correct
73 Correct 89 ms 197952 KB Output is correct
74 Correct 395 ms 197952 KB Output is correct
75 Runtime error 11 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
76 Runtime error 11 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
77 Incorrect 46 ms 197952 KB Output isn't correct
78 Incorrect 4 ms 197952 KB Output isn't correct
79 Runtime error 9 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
80 Runtime error 10 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
81 Correct 225 ms 197952 KB Output is correct
82 Runtime error 10 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
83 Incorrect 4 ms 197952 KB Output isn't correct
84 Runtime error 11 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
85 Runtime error 12 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
86 Runtime error 16 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
87 Runtime error 11 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
88 Runtime error 9 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
89 Runtime error 9 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
90 Runtime error 9 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
91 Runtime error 11 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
92 Runtime error 10 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
93 Runtime error 11 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
94 Runtime error 9 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
95 Runtime error 9 ms 197952 KB Execution killed with signal 11 (could be triggered by violating memory limits)