답안 #66247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66247 2018-08-10T05:38:11 Z 윤교준(#1888) 초음속철도 (OJUZ11_rail) C++11
45 / 100
616 ms 16848 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int MAXN = 200005;

inline void add(int &a, int b) { a += b; if(MOD <= a) a -= MOD; }
inline void mul(int &a) { a += a; if(MOD <= a) a -= MOD; }
inline int addint(int a, int b) { add(a, b); return a; }

struct SEG {
	SEG() { init(); }
	int d[MAXN*4], pd[MAXN*4];

	void init() { fill(pd, pd+MAXN*4, 1); }
	void prop(int i, int s, int e) {
		if(1 == pd[i]) return;
		if(s != e) {
			pd[i<<1] = ll(pd[i<<1]) * pd[i] % MOD;
			pd[i<<1|1] = ll(pd[i<<1|1]) * pd[i] % MOD;
		}
		d[i] = ll(d[i]) * pd[i] % MOD;
		pd[i] = 1;
	}

	void upd(int i, int s, int e, int p, int q) {
		prop(i, s, e); if(q < p || e < p || q < s) return;
		if(p <= s && e <= q) {
			mul(pd[i]);
			prop(i, s, e);
			return;
		}
		int m = (s+e) >> 1;
		upd(i<<1, s, m, p, q); upd(i<<1|1, m+1, e, p, q);
		d[i] = addint(d[i<<1], d[i<<1|1]);
	}
	void updx(int i, int s, int e, int x, int r) {
		prop(i, s, e); if(x < s || e < x) return;
		if(s == e) {
			add(d[i], r);
			return;
		}
		int m = (s+e) >> 1;
		updx(i<<1, s, m, x, r); updx(i<<1|1, m+1, e, x, r);
		d[i] = addint(d[i<<1], d[i<<1|1]);
	}

	int get(int i, int s, int e, int p, int q) {
		prop(i, s, e); if(q < p || e < p || q < s) return 0;
		if(p <= s && e <= q) return d[i];
		int m = (s+e) >> 1;
		return addint(get(i<<1, s, m, p, q), get(i<<1|1, m+1, e, p, q));
	}
} seg;

int A[MAXN], B[MAXN], O[MAXN];

int N, M;

int main() {
	ios::sync_with_stdio(false);

	cin >> M >> N;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];

	{
		vector<int> V;
		V.eb(1); V.eb(M);
		for(int i = 1; i <= N; i++) {
			V.eb(A[i]);
			V.eb(B[i]);
		}
		sorv(V); univ(V);
		M = sz(V);
		for(int i = 1; i <= N; i++) {
			A[i] = int(lower_bound(allv(V), A[i]) - V.begin()) + 1;
			B[i] = int(lower_bound(allv(V), B[i]) - V.begin()) + 1;
		}
	}
	iota(O, O+N+1, 0);
	sort(O+1, O+N+1, [&](int a, int b) { return B[a] < B[b]; });

	seg.updx(1, 1, M, 1, 1);
	for(int oi = 1, i; oi <= N; oi++) {
		i = O[oi];
		int s = A[i], e = B[i], ret = 0;
		ret = seg.get(1, 1, M, s, e-1);
		seg.upd(1, 1, M, 1, s-1);
		seg.upd(1, 1, M, e, M);
		seg.updx(1, 1, M, e, ret);
	}
	
	cout << seg.get(1, 1, M, M, M) << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 6 ms 3684 KB Output is correct
3 Correct 5 ms 3684 KB Output is correct
4 Correct 5 ms 3684 KB Output is correct
5 Correct 5 ms 3708 KB Output is correct
6 Correct 5 ms 3708 KB Output is correct
7 Correct 5 ms 3776 KB Output is correct
8 Correct 5 ms 3820 KB Output is correct
9 Correct 5 ms 3820 KB Output is correct
10 Correct 6 ms 3820 KB Output is correct
11 Correct 6 ms 3820 KB Output is correct
12 Correct 7 ms 3820 KB Output is correct
13 Correct 6 ms 3820 KB Output is correct
14 Correct 5 ms 3820 KB Output is correct
15 Correct 5 ms 3820 KB Output is correct
16 Correct 5 ms 3820 KB Output is correct
17 Correct 6 ms 3820 KB Output is correct
18 Correct 5 ms 3820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 6 ms 3684 KB Output is correct
3 Correct 5 ms 3684 KB Output is correct
4 Correct 5 ms 3684 KB Output is correct
5 Correct 5 ms 3708 KB Output is correct
6 Correct 5 ms 3708 KB Output is correct
7 Correct 5 ms 3776 KB Output is correct
8 Correct 5 ms 3820 KB Output is correct
9 Correct 5 ms 3820 KB Output is correct
10 Correct 6 ms 3820 KB Output is correct
11 Correct 6 ms 3820 KB Output is correct
12 Correct 7 ms 3820 KB Output is correct
13 Correct 6 ms 3820 KB Output is correct
14 Correct 5 ms 3820 KB Output is correct
15 Correct 5 ms 3820 KB Output is correct
16 Correct 5 ms 3820 KB Output is correct
17 Correct 6 ms 3820 KB Output is correct
18 Correct 5 ms 3820 KB Output is correct
19 Correct 6 ms 3820 KB Output is correct
20 Correct 5 ms 3820 KB Output is correct
21 Correct 6 ms 3820 KB Output is correct
22 Correct 6 ms 3820 KB Output is correct
23 Correct 5 ms 3820 KB Output is correct
24 Correct 6 ms 3820 KB Output is correct
25 Correct 5 ms 3820 KB Output is correct
26 Correct 5 ms 3820 KB Output is correct
27 Correct 5 ms 3820 KB Output is correct
28 Correct 5 ms 3820 KB Output is correct
29 Correct 5 ms 3820 KB Output is correct
30 Correct 6 ms 3820 KB Output is correct
31 Correct 4 ms 3820 KB Output is correct
32 Correct 6 ms 3820 KB Output is correct
33 Correct 6 ms 3820 KB Output is correct
34 Correct 6 ms 3820 KB Output is correct
35 Correct 5 ms 3820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3820 KB Output is correct
2 Correct 5 ms 3820 KB Output is correct
3 Correct 5 ms 3820 KB Output is correct
4 Correct 12 ms 3964 KB Output is correct
5 Correct 299 ms 7536 KB Output is correct
6 Runtime error 366 ms 16440 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 357 ms 16524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Correct 6 ms 16524 KB Output is correct
9 Runtime error 339 ms 16524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 373 ms 16524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Correct 163 ms 16524 KB Output is correct
12 Runtime error 361 ms 16620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 372 ms 16620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Correct 100 ms 16620 KB Output is correct
15 Correct 452 ms 16620 KB Output is correct
16 Correct 114 ms 16620 KB Output is correct
17 Runtime error 369 ms 16620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 355 ms 16796 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 347 ms 16796 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 6 ms 3684 KB Output is correct
3 Correct 5 ms 3684 KB Output is correct
4 Correct 5 ms 3684 KB Output is correct
5 Correct 5 ms 3708 KB Output is correct
6 Correct 5 ms 3708 KB Output is correct
7 Correct 5 ms 3776 KB Output is correct
8 Correct 5 ms 3820 KB Output is correct
9 Correct 5 ms 3820 KB Output is correct
10 Correct 6 ms 3820 KB Output is correct
11 Correct 6 ms 3820 KB Output is correct
12 Correct 7 ms 3820 KB Output is correct
13 Correct 6 ms 3820 KB Output is correct
14 Correct 5 ms 3820 KB Output is correct
15 Correct 5 ms 3820 KB Output is correct
16 Correct 5 ms 3820 KB Output is correct
17 Correct 6 ms 3820 KB Output is correct
18 Correct 5 ms 3820 KB Output is correct
19 Correct 6 ms 3820 KB Output is correct
20 Correct 5 ms 3820 KB Output is correct
21 Correct 6 ms 3820 KB Output is correct
22 Correct 6 ms 3820 KB Output is correct
23 Correct 5 ms 3820 KB Output is correct
24 Correct 6 ms 3820 KB Output is correct
25 Correct 5 ms 3820 KB Output is correct
26 Correct 5 ms 3820 KB Output is correct
27 Correct 5 ms 3820 KB Output is correct
28 Correct 5 ms 3820 KB Output is correct
29 Correct 5 ms 3820 KB Output is correct
30 Correct 6 ms 3820 KB Output is correct
31 Correct 4 ms 3820 KB Output is correct
32 Correct 6 ms 3820 KB Output is correct
33 Correct 6 ms 3820 KB Output is correct
34 Correct 6 ms 3820 KB Output is correct
35 Correct 5 ms 3820 KB Output is correct
36 Correct 16 ms 16796 KB Output is correct
37 Correct 13 ms 16796 KB Output is correct
38 Correct 11 ms 16796 KB Output is correct
39 Correct 7 ms 16796 KB Output is correct
40 Correct 12 ms 16796 KB Output is correct
41 Correct 13 ms 16796 KB Output is correct
42 Correct 16 ms 16796 KB Output is correct
43 Correct 5 ms 16796 KB Output is correct
44 Correct 13 ms 16796 KB Output is correct
45 Correct 8 ms 16796 KB Output is correct
46 Correct 13 ms 16796 KB Output is correct
47 Correct 14 ms 16796 KB Output is correct
48 Correct 16 ms 16796 KB Output is correct
49 Correct 12 ms 16796 KB Output is correct
50 Correct 8 ms 16796 KB Output is correct
51 Correct 9 ms 16796 KB Output is correct
52 Correct 8 ms 16796 KB Output is correct
53 Correct 21 ms 16796 KB Output is correct
54 Correct 9 ms 16796 KB Output is correct
55 Correct 15 ms 16796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 6 ms 3684 KB Output is correct
3 Correct 5 ms 3684 KB Output is correct
4 Correct 5 ms 3684 KB Output is correct
5 Correct 5 ms 3708 KB Output is correct
6 Correct 5 ms 3708 KB Output is correct
7 Correct 5 ms 3776 KB Output is correct
8 Correct 5 ms 3820 KB Output is correct
9 Correct 5 ms 3820 KB Output is correct
10 Correct 6 ms 3820 KB Output is correct
11 Correct 6 ms 3820 KB Output is correct
12 Correct 7 ms 3820 KB Output is correct
13 Correct 6 ms 3820 KB Output is correct
14 Correct 5 ms 3820 KB Output is correct
15 Correct 5 ms 3820 KB Output is correct
16 Correct 5 ms 3820 KB Output is correct
17 Correct 6 ms 3820 KB Output is correct
18 Correct 5 ms 3820 KB Output is correct
19 Correct 6 ms 3820 KB Output is correct
20 Correct 5 ms 3820 KB Output is correct
21 Correct 6 ms 3820 KB Output is correct
22 Correct 6 ms 3820 KB Output is correct
23 Correct 5 ms 3820 KB Output is correct
24 Correct 6 ms 3820 KB Output is correct
25 Correct 5 ms 3820 KB Output is correct
26 Correct 5 ms 3820 KB Output is correct
27 Correct 5 ms 3820 KB Output is correct
28 Correct 5 ms 3820 KB Output is correct
29 Correct 5 ms 3820 KB Output is correct
30 Correct 6 ms 3820 KB Output is correct
31 Correct 4 ms 3820 KB Output is correct
32 Correct 6 ms 3820 KB Output is correct
33 Correct 6 ms 3820 KB Output is correct
34 Correct 6 ms 3820 KB Output is correct
35 Correct 5 ms 3820 KB Output is correct
36 Correct 5 ms 3820 KB Output is correct
37 Correct 5 ms 3820 KB Output is correct
38 Correct 5 ms 3820 KB Output is correct
39 Correct 12 ms 3964 KB Output is correct
40 Correct 299 ms 7536 KB Output is correct
41 Runtime error 366 ms 16440 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 357 ms 16524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
43 Correct 6 ms 16524 KB Output is correct
44 Runtime error 339 ms 16524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Runtime error 373 ms 16524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
46 Correct 163 ms 16524 KB Output is correct
47 Runtime error 361 ms 16620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Runtime error 372 ms 16620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Correct 100 ms 16620 KB Output is correct
50 Correct 452 ms 16620 KB Output is correct
51 Correct 114 ms 16620 KB Output is correct
52 Runtime error 369 ms 16620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Runtime error 355 ms 16796 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Runtime error 347 ms 16796 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Correct 16 ms 16796 KB Output is correct
56 Correct 13 ms 16796 KB Output is correct
57 Correct 11 ms 16796 KB Output is correct
58 Correct 7 ms 16796 KB Output is correct
59 Correct 12 ms 16796 KB Output is correct
60 Correct 13 ms 16796 KB Output is correct
61 Correct 16 ms 16796 KB Output is correct
62 Correct 5 ms 16796 KB Output is correct
63 Correct 13 ms 16796 KB Output is correct
64 Correct 8 ms 16796 KB Output is correct
65 Correct 13 ms 16796 KB Output is correct
66 Correct 14 ms 16796 KB Output is correct
67 Correct 16 ms 16796 KB Output is correct
68 Correct 12 ms 16796 KB Output is correct
69 Correct 8 ms 16796 KB Output is correct
70 Correct 9 ms 16796 KB Output is correct
71 Correct 8 ms 16796 KB Output is correct
72 Correct 21 ms 16796 KB Output is correct
73 Correct 9 ms 16796 KB Output is correct
74 Correct 15 ms 16796 KB Output is correct
75 Runtime error 349 ms 16796 KB Execution killed with signal 11 (could be triggered by violating memory limits)
76 Correct 367 ms 16796 KB Output is correct
77 Correct 351 ms 16796 KB Output is correct
78 Correct 95 ms 16796 KB Output is correct
79 Correct 458 ms 16796 KB Output is correct
80 Runtime error 359 ms 16836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
81 Correct 14 ms 16836 KB Output is correct
82 Runtime error 315 ms 16836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
83 Correct 88 ms 16836 KB Output is correct
84 Runtime error 298 ms 16848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
85 Correct 616 ms 16848 KB Output is correct
86 Correct 599 ms 16848 KB Output is correct
87 Correct 190 ms 16848 KB Output is correct
88 Correct 169 ms 16848 KB Output is correct
89 Runtime error 358 ms 16848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
90 Runtime error 360 ms 16848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
91 Runtime error 415 ms 16848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
92 Runtime error 428 ms 16848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
93 Correct 574 ms 16848 KB Output is correct
94 Runtime error 349 ms 16848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
95 Runtime error 344 ms 16848 KB Execution killed with signal 11 (could be triggered by violating memory limits)