Submission #2232830
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i, n) for (int i = 0; i < (n); ++i) #define SIZE(a) ((int)(a).size()) const int N = 200005; const int mod = 1000*1000*1000 + 7; int n; pair<int,int> a[N]; int lf[N], rt[N]; int seg[N]; int f[N]; inline void add(int &x, int y) { x += y; if (x >= mod) x -= mod; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; REP(i, n) cin >> a[i].first >> a[i].second; REP(i, n+2) seg[i] = -1; sort(a, a + n); vector<pair<int,int>> b(n); REP(i, n) b[i] = {a[i].second, i}; sort(b.begin(), b.end()); int mx = -1; REP(i, n) { mx = max(mx, b[i].second); rt[b[i].second] = mx+1; } int mn = n; for (int i = n-1; i >= 0; --i) { mn = min(mn, b[i].second); lf[b[i].second] = mn+1; } REP(i, n) { seg[rt[i]] = max(seg[rt[i]], lf[i]); } int sum = 1; f[0] = 1; mx = -1; int j = 0; for (int i = 1; i <= n+1; ++i) { mx = max(mx, seg[i-1]); while (j < mx) { add(sum, mod-f[j]); ++j; } add(f[i], sum); add(sum, sum); } cout << f[n+1] << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Mr.Aoki Incubator |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 1200 |
Code Size | 1088 Byte |
Status | AC |
Exec Time | 77 ms |
Memory | 6528 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 62 ms | 6528 KB |
02.txt | AC | 62 ms | 6528 KB |
03.txt | AC | 74 ms | 6528 KB |
04.txt | AC | 62 ms | 6528 KB |
05.txt | AC | 63 ms | 6528 KB |
06.txt | AC | 77 ms | 6528 KB |
07.txt | AC | 62 ms | 6528 KB |
08.txt | AC | 62 ms | 6528 KB |
09.txt | AC | 62 ms | 6528 KB |
10.txt | AC | 48 ms | 6528 KB |
11.txt | AC | 50 ms | 6528 KB |
12.txt | AC | 62 ms | 6528 KB |
13.txt | AC | 52 ms | 6528 KB |
14.txt | AC | 50 ms | 6528 KB |
15.txt | AC | 63 ms | 6528 KB |
16.txt | AC | 50 ms | 6528 KB |
17.txt | AC | 50 ms | 6528 KB |
18.txt | AC | 65 ms | 6528 KB |
19.txt | AC | 50 ms | 6528 KB |
20.txt | AC | 50 ms | 6528 KB |
21.txt | AC | 65 ms | 6528 KB |
22.txt | AC | 52 ms | 6528 KB |
23.txt | AC | 53 ms | 6528 KB |
24.txt | AC | 64 ms | 6528 KB |
25.txt | AC | 51 ms | 6528 KB |
26.txt | AC | 51 ms | 6528 KB |
27.txt | AC | 63 ms | 6528 KB |
28.txt | AC | 50 ms | 6528 KB |
29.txt | AC | 50 ms | 6528 KB |
30.txt | AC | 62 ms | 6528 KB |
31.txt | AC | 1 ms | 2304 KB |
32.txt | AC | 2 ms | 2304 KB |
33.txt | AC | 2 ms | 2304 KB |
34.txt | AC | 2 ms | 2304 KB |
s1.txt | AC | 2 ms | 2304 KB |
s2.txt | AC | 2 ms | 2304 KB |