Submission #2232743
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<int> s; REP(i, n) { while (!s.empty() && a[s.back()].second < a[i].second) { s.pop_back(); } s.push_back(i); lf[i] = s[0]+1; } s.clear(); for (int i = n-1; i >= 0; --i) { while (!s.empty() && a[s.back()].second > a[i].second) { s.pop_back(); } s.push_back(i); rt[i] = s[0]+1; seg[rt[i]] = max(seg[rt[i]], lf[i]); } int sum = 1; f[0] = 1; int 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 | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1105 Byte |
Status | WA |
Exec Time | 61 ms |
Memory | 5876 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 50 ms | 4992 KB |
02.txt | WA | 50 ms | 4992 KB |
03.txt | WA | 61 ms | 4992 KB |
04.txt | WA | 49 ms | 4992 KB |
05.txt | WA | 50 ms | 4992 KB |
06.txt | WA | 61 ms | 4992 KB |
07.txt | WA | 49 ms | 4992 KB |
08.txt | WA | 50 ms | 4992 KB |
09.txt | AC | 58 ms | 4992 KB |
10.txt | AC | 46 ms | 5876 KB |
11.txt | AC | 46 ms | 4992 KB |
12.txt | AC | 58 ms | 4992 KB |
13.txt | WA | 46 ms | 4992 KB |
14.txt | WA | 46 ms | 4992 KB |
15.txt | WA | 61 ms | 4992 KB |
16.txt | WA | 46 ms | 4992 KB |
17.txt | AC | 46 ms | 4992 KB |
18.txt | AC | 58 ms | 4992 KB |
19.txt | AC | 46 ms | 4992 KB |
20.txt | AC | 46 ms | 4992 KB |
21.txt | WA | 61 ms | 4992 KB |
22.txt | WA | 49 ms | 4992 KB |
23.txt | WA | 49 ms | 4992 KB |
24.txt | WA | 61 ms | 4992 KB |
25.txt | WA | 48 ms | 4992 KB |
26.txt | WA | 46 ms | 4992 KB |
27.txt | WA | 58 ms | 4992 KB |
28.txt | WA | 46 ms | 4992 KB |
29.txt | AC | 46 ms | 4992 KB |
30.txt | AC | 58 ms | 4992 KB |
31.txt | AC | 2 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 |