답안 #20471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20471 2017-02-12T01:24:50 Z sgc109(#57, sgc109) 초음속철도 (OJUZ11_rail) C++11
45 / 100
506 ms 393696 KB
// #include <bits/stdc++.h>
#include <unordered_set>
// #include <unordered_map>
#include <vector>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define FOR(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)z
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vector<int> > vvi;
typedef pair<int,pair<int,int> > piii;
typedef vector<piii> viii;
const double EPSILON = 1e-9;
const double PI = acos(-1);
const int MOD = 1000000007;
const int INF = 0x3c3c3c3c;
const long long INFL = 0x3c3c3c3c3c3c3c3c;
const int MAX_N = 102;

struct Range{
	int l,r;
	bool operator<(Range& rhs){
		if(l==rhs.l) return r<rhs.r;
		return l<rhs.l;
	}
};
int N,M,a,b,E;
Range ranges[5003];
ll dp[5003][10003];
unordered_set<int> us;
ll solve(int pos, int last){
	if(pos==M) return last==E;
	if(ranges[pos].l!=0&&last<ranges[pos].l) return 0;
	ll& cache = dp[pos][last+1];
	if(cache!=-1) return cache;
	return cache = (solve(pos+1,max(last,ranges[pos].r))+solve(pos+1,last))%MOD;
}
int main() {
	memset(dp,-1,sizeof(dp));
	vi sorted;
	inp2(N,M);
	us.insert(1),sorted.pb(1);
	us.insert(N),sorted.pb(N);
	FOR(i,M){
		inp2(a,b);
		ranges[i]=Range{a,b};
		if(!us.count(a)) us.insert(a),sorted.pb(a);
		if(!us.count(b)) us.insert(b),sorted.pb(b);
	}
	sort(all(sorted));
	E=sz(sorted)-1;
	FOR(i,M) {
		ranges[i].l=lower_bound(all(sorted),ranges[i].l)-sorted.begin();
		ranges[i].r=lower_bound(all(sorted),ranges[i].r)-sorted.begin();
	}
	sort(ranges,ranges+M);
	// 좌표압축 + 정렬까지 완료

	printf("%lld", solve(0,-1));
	return 0;
}

Compilation message

rail.cpp: In function 'int main()':
rail.cpp:64:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  inp2(N,M);
           ^
rail.cpp:68:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   inp2(a,b);
            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 393044 KB Output is correct
2 Correct 16 ms 393044 KB Output is correct
3 Correct 39 ms 393044 KB Output is correct
4 Correct 46 ms 393044 KB Output is correct
5 Correct 39 ms 393044 KB Output is correct
6 Correct 19 ms 393044 KB Output is correct
7 Correct 29 ms 393044 KB Output is correct
8 Correct 16 ms 393044 KB Output is correct
9 Correct 33 ms 393044 KB Output is correct
10 Correct 13 ms 393044 KB Output is correct
11 Correct 6 ms 393044 KB Output is correct
12 Correct 19 ms 393044 KB Output is correct
13 Correct 33 ms 393044 KB Output is correct
14 Correct 29 ms 393044 KB Output is correct
15 Correct 29 ms 393044 KB Output is correct
16 Correct 26 ms 393044 KB Output is correct
17 Correct 26 ms 393044 KB Output is correct
18 Correct 16 ms 393044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 393044 KB Output is correct
2 Correct 16 ms 393044 KB Output is correct
3 Correct 39 ms 393044 KB Output is correct
4 Correct 46 ms 393044 KB Output is correct
5 Correct 39 ms 393044 KB Output is correct
6 Correct 19 ms 393044 KB Output is correct
7 Correct 29 ms 393044 KB Output is correct
8 Correct 16 ms 393044 KB Output is correct
9 Correct 33 ms 393044 KB Output is correct
10 Correct 13 ms 393044 KB Output is correct
11 Correct 6 ms 393044 KB Output is correct
12 Correct 19 ms 393044 KB Output is correct
13 Correct 33 ms 393044 KB Output is correct
14 Correct 29 ms 393044 KB Output is correct
15 Correct 29 ms 393044 KB Output is correct
16 Correct 26 ms 393044 KB Output is correct
17 Correct 26 ms 393044 KB Output is correct
18 Correct 16 ms 393044 KB Output is correct
19 Correct 39 ms 393044 KB Output is correct
20 Correct 46 ms 393044 KB Output is correct
21 Correct 29 ms 393044 KB Output is correct
22 Correct 33 ms 393044 KB Output is correct
23 Correct 29 ms 393044 KB Output is correct
24 Correct 16 ms 393044 KB Output is correct
25 Correct 39 ms 393044 KB Output is correct
26 Correct 36 ms 393044 KB Output is correct
27 Correct 33 ms 393044 KB Output is correct
28 Correct 19 ms 393044 KB Output is correct
29 Correct 33 ms 393044 KB Output is correct
30 Correct 26 ms 393044 KB Output is correct
31 Correct 16 ms 393044 KB Output is correct
32 Correct 19 ms 393044 KB Output is correct
33 Correct 29 ms 393044 KB Output is correct
34 Correct 29 ms 393044 KB Output is correct
35 Correct 26 ms 393044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 393044 KB Output is correct
2 Correct 36 ms 393044 KB Output is correct
3 Correct 49 ms 393044 KB Output is correct
4 Correct 33 ms 393288 KB Output is correct
5 Runtime error 59 ms 393340 KB Execution killed because of forbidden syscall futex (202)
6 Runtime error 23 ms 393696 KB Execution killed because of forbidden syscall futex (202)
7 Incorrect 39 ms 393612 KB Output isn't correct
8 Correct 36 ms 393044 KB Output is correct
9 Runtime error 26 ms 393696 KB Execution killed because of forbidden syscall futex (202)
10 Runtime error 39 ms 393696 KB Execution killed because of forbidden syscall futex (202)
11 Runtime error 29 ms 393340 KB Execution killed because of forbidden syscall futex (202)
12 Runtime error 36 ms 393696 KB Execution killed because of forbidden syscall futex (202)
13 Runtime error 29 ms 393696 KB Execution killed because of forbidden syscall futex (202)
14 Runtime error 9 ms 393044 KB Execution killed because of forbidden syscall futex (202)
15 Runtime error 33 ms 393696 KB Execution killed because of forbidden syscall futex (202)
16 Runtime error 23 ms 393044 KB Execution killed because of forbidden syscall futex (202)
17 Runtime error 36 ms 393696 KB Execution killed because of forbidden syscall futex (202)
18 Runtime error 36 ms 393696 KB Execution killed because of forbidden syscall futex (202)
19 Runtime error 29 ms 393696 KB Execution killed because of forbidden syscall futex (202)
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 393044 KB Output is correct
2 Correct 16 ms 393044 KB Output is correct
3 Correct 39 ms 393044 KB Output is correct
4 Correct 46 ms 393044 KB Output is correct
5 Correct 39 ms 393044 KB Output is correct
6 Correct 19 ms 393044 KB Output is correct
7 Correct 29 ms 393044 KB Output is correct
8 Correct 16 ms 393044 KB Output is correct
9 Correct 33 ms 393044 KB Output is correct
10 Correct 13 ms 393044 KB Output is correct
11 Correct 6 ms 393044 KB Output is correct
12 Correct 19 ms 393044 KB Output is correct
13 Correct 33 ms 393044 KB Output is correct
14 Correct 29 ms 393044 KB Output is correct
15 Correct 29 ms 393044 KB Output is correct
16 Correct 26 ms 393044 KB Output is correct
17 Correct 26 ms 393044 KB Output is correct
18 Correct 16 ms 393044 KB Output is correct
19 Correct 39 ms 393044 KB Output is correct
20 Correct 46 ms 393044 KB Output is correct
21 Correct 29 ms 393044 KB Output is correct
22 Correct 33 ms 393044 KB Output is correct
23 Correct 29 ms 393044 KB Output is correct
24 Correct 16 ms 393044 KB Output is correct
25 Correct 39 ms 393044 KB Output is correct
26 Correct 36 ms 393044 KB Output is correct
27 Correct 33 ms 393044 KB Output is correct
28 Correct 19 ms 393044 KB Output is correct
29 Correct 33 ms 393044 KB Output is correct
30 Correct 26 ms 393044 KB Output is correct
31 Correct 16 ms 393044 KB Output is correct
32 Correct 19 ms 393044 KB Output is correct
33 Correct 29 ms 393044 KB Output is correct
34 Correct 29 ms 393044 KB Output is correct
35 Correct 26 ms 393044 KB Output is correct
36 Correct 376 ms 393672 KB Output is correct
37 Correct 296 ms 393632 KB Output is correct
38 Correct 213 ms 393244 KB Output is correct
39 Correct 33 ms 393148 KB Output is correct
40 Correct 29 ms 393452 KB Output is correct
41 Correct 59 ms 393564 KB Output is correct
42 Correct 199 ms 393676 KB Output is correct
43 Correct 26 ms 393044 KB Output is correct
44 Correct 506 ms 393448 KB Output is correct
45 Correct 26 ms 393156 KB Output is correct
46 Correct 363 ms 393444 KB Output is correct
47 Correct 273 ms 393444 KB Output is correct
48 Correct 239 ms 393448 KB Output is correct
49 Correct 33 ms 393152 KB Output is correct
50 Correct 9 ms 393156 KB Output is correct
51 Correct 29 ms 393152 KB Output is correct
52 Correct 43 ms 393180 KB Output is correct
53 Correct 39 ms 393564 KB Output is correct
54 Correct 116 ms 393200 KB Output is correct
55 Correct 36 ms 393564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 393044 KB Output is correct
2 Correct 16 ms 393044 KB Output is correct
3 Correct 39 ms 393044 KB Output is correct
4 Correct 46 ms 393044 KB Output is correct
5 Correct 39 ms 393044 KB Output is correct
6 Correct 19 ms 393044 KB Output is correct
7 Correct 29 ms 393044 KB Output is correct
8 Correct 16 ms 393044 KB Output is correct
9 Correct 33 ms 393044 KB Output is correct
10 Correct 13 ms 393044 KB Output is correct
11 Correct 6 ms 393044 KB Output is correct
12 Correct 19 ms 393044 KB Output is correct
13 Correct 33 ms 393044 KB Output is correct
14 Correct 29 ms 393044 KB Output is correct
15 Correct 29 ms 393044 KB Output is correct
16 Correct 26 ms 393044 KB Output is correct
17 Correct 26 ms 393044 KB Output is correct
18 Correct 16 ms 393044 KB Output is correct
19 Correct 39 ms 393044 KB Output is correct
20 Correct 46 ms 393044 KB Output is correct
21 Correct 29 ms 393044 KB Output is correct
22 Correct 33 ms 393044 KB Output is correct
23 Correct 29 ms 393044 KB Output is correct
24 Correct 16 ms 393044 KB Output is correct
25 Correct 39 ms 393044 KB Output is correct
26 Correct 36 ms 393044 KB Output is correct
27 Correct 33 ms 393044 KB Output is correct
28 Correct 19 ms 393044 KB Output is correct
29 Correct 33 ms 393044 KB Output is correct
30 Correct 26 ms 393044 KB Output is correct
31 Correct 16 ms 393044 KB Output is correct
32 Correct 19 ms 393044 KB Output is correct
33 Correct 29 ms 393044 KB Output is correct
34 Correct 29 ms 393044 KB Output is correct
35 Correct 26 ms 393044 KB Output is correct
36 Correct 43 ms 393044 KB Output is correct
37 Correct 36 ms 393044 KB Output is correct
38 Correct 49 ms 393044 KB Output is correct
39 Correct 33 ms 393288 KB Output is correct
40 Runtime error 59 ms 393340 KB Execution killed because of forbidden syscall futex (202)
41 Runtime error 23 ms 393696 KB Execution killed because of forbidden syscall futex (202)
42 Incorrect 39 ms 393612 KB Output isn't correct
43 Correct 36 ms 393044 KB Output is correct
44 Runtime error 26 ms 393696 KB Execution killed because of forbidden syscall futex (202)
45 Runtime error 39 ms 393696 KB Execution killed because of forbidden syscall futex (202)
46 Runtime error 29 ms 393340 KB Execution killed because of forbidden syscall futex (202)
47 Runtime error 36 ms 393696 KB Execution killed because of forbidden syscall futex (202)
48 Runtime error 29 ms 393696 KB Execution killed because of forbidden syscall futex (202)
49 Runtime error 9 ms 393044 KB Execution killed because of forbidden syscall futex (202)
50 Runtime error 33 ms 393696 KB Execution killed because of forbidden syscall futex (202)
51 Runtime error 23 ms 393044 KB Execution killed because of forbidden syscall futex (202)
52 Runtime error 36 ms 393696 KB Execution killed because of forbidden syscall futex (202)
53 Runtime error 36 ms 393696 KB Execution killed because of forbidden syscall futex (202)
54 Runtime error 29 ms 393696 KB Execution killed because of forbidden syscall futex (202)
55 Correct 376 ms 393672 KB Output is correct
56 Correct 296 ms 393632 KB Output is correct
57 Correct 213 ms 393244 KB Output is correct
58 Correct 33 ms 393148 KB Output is correct
59 Correct 29 ms 393452 KB Output is correct
60 Correct 59 ms 393564 KB Output is correct
61 Correct 199 ms 393676 KB Output is correct
62 Correct 26 ms 393044 KB Output is correct
63 Correct 506 ms 393448 KB Output is correct
64 Correct 26 ms 393156 KB Output is correct
65 Correct 363 ms 393444 KB Output is correct
66 Correct 273 ms 393444 KB Output is correct
67 Correct 239 ms 393448 KB Output is correct
68 Correct 33 ms 393152 KB Output is correct
69 Correct 9 ms 393156 KB Output is correct
70 Correct 29 ms 393152 KB Output is correct
71 Correct 43 ms 393180 KB Output is correct
72 Correct 39 ms 393564 KB Output is correct
73 Correct 116 ms 393200 KB Output is correct
74 Correct 36 ms 393564 KB Output is correct
75 Runtime error 39 ms 393696 KB Execution killed because of forbidden syscall futex (202)
76 Runtime error 23 ms 393696 KB Execution killed because of forbidden syscall futex (202)
77 Incorrect 53 ms 393180 KB Output isn't correct
78 Incorrect 33 ms 393044 KB Output isn't correct
79 Runtime error 29 ms 393564 KB Execution killed because of forbidden syscall futex (202)
80 Runtime error 36 ms 393696 KB Execution killed because of forbidden syscall futex (202)
81 Correct 336 ms 393448 KB Output is correct
82 Runtime error 23 ms 393696 KB Execution killed because of forbidden syscall futex (202)
83 Runtime error 33 ms 393044 KB Execution killed because of forbidden syscall futex (202)
84 Runtime error 13 ms 393564 KB Execution killed because of forbidden syscall futex (202)
85 Runtime error 29 ms 393696 KB Execution killed because of forbidden syscall futex (202)
86 Runtime error 23 ms 393696 KB Execution killed because of forbidden syscall futex (202)
87 Runtime error 29 ms 393044 KB Execution killed because of forbidden syscall futex (202)
88 Runtime error 46 ms 393044 KB Execution killed because of forbidden syscall futex (202)
89 Runtime error 33 ms 393696 KB Execution killed because of forbidden syscall futex (202)
90 Runtime error 46 ms 393696 KB Execution killed because of forbidden syscall futex (202)
91 Runtime error 26 ms 393696 KB Execution killed because of forbidden syscall futex (202)
92 Runtime error 26 ms 393696 KB Execution killed because of forbidden syscall futex (202)
93 Runtime error 13 ms 393696 KB Execution killed because of forbidden syscall futex (202)
94 Runtime error 19 ms 393696 KB Execution killed because of forbidden syscall futex (202)
95 Runtime error 33 ms 393696 KB Execution killed because of forbidden syscall futex (202)