Submission #1555104
Source Code Expand
#include <cstdio> #include <cctype> #include <algorithm> namespace Zeonfai { inline int getInt() { int a = 0, sgn = 1; char c; while(! isdigit(c = getchar())) if(c == '-') sgn *= -1; while(isdigit(c)) a = a * 10 + c - '0', c = getchar(); return a * sgn; } } using namespace std; const int N = (int)2e5; int n; int mn[N + 1], mx[N + 1]; struct point { int v, pos; inline int operator <(const point &a) const {return v == a.v ? pos < a.pos : v < a.v;} // 注意速度相同的处理 }p[N + 1]; struct section { int L, R; inline int operator <(const section &a) const {return R == a.R ? L < a.L : R < a.R;} }sec[N + 1]; struct binaryIndexedTree { long long a[N + 2]; inline void modify(int pos, int x) { for(int i = pos + 1; i <= n + 1; i += i & - i) a[i] += x; } long long query(int pos) { long long res = 0; for(int i = pos + 1; i; i -= i & - i) res += a[i]; return res; } inline long long query(int L, int R) {return query(R) - query(L - 1);} }BIT; int main() { using namespace Zeonfai; n = getInt(); for(int i = 1; i <= n; ++ i) p[i].pos = getInt(), p[i].v = getInt(); sort(p + 1, p + n + 1); for(int i = 1; i <= n; ++ i) mx[i] = i == 1 ? p[i].pos : max(mx[i - 1], p[i].pos); for(int i = n; i; -- i) mn[i] = i == n ? p[i].pos : min(mn[i + 1], p[i].pos); for(int i = 1; i <= n; ++ i) { int L = 1, R = i - 1, pos = i; while(L <= R) if(mx[L + R >> 1] > p[i].pos) {pos = L + R >> 1; R = (L + R >> 1) - 1;} else L = (L + R >> 1) + 1; sec[i].L = pos; L = i + 1; R = n; pos = i; while(L <= R) if(mn[L + R >> 1] < p[i].pos) {pos = L + R >> 1; L = (L + R >> 1) + 1;} else R = (L + R >> 1) - 1; sec[i].R = pos; } sort(sec + 1, sec + n + 1); BIT.modify(0, 1); for(int i = 1; i <= n; ++ i) BIT.modify(sec[i].R, BIT.query(sec[i].L - 1, sec[i].R)); printf("%lld\n", BIT.query(n, n)); } /* 5 4 9 3 6 8 1 9 2 5 1 */
Submission Info
Submission Time | |
---|---|
Task | E - Mr.Aoki Incubator |
User | ZeonfaiHo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2115 Byte |
Status | WA |
Exec Time | 75 ms |
Memory | 6400 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 | 66 ms | 4992 KB |
02.txt | WA | 65 ms | 4992 KB |
03.txt | WA | 65 ms | 4864 KB |
04.txt | WA | 65 ms | 4992 KB |
05.txt | WA | 63 ms | 4992 KB |
06.txt | WA | 64 ms | 4992 KB |
07.txt | WA | 66 ms | 4992 KB |
08.txt | WA | 63 ms | 4992 KB |
09.txt | AC | 65 ms | 6400 KB |
10.txt | WA | 49 ms | 4864 KB |
11.txt | WA | 53 ms | 6400 KB |
12.txt | WA | 64 ms | 6400 KB |
13.txt | WA | 53 ms | 6400 KB |
14.txt | WA | 54 ms | 6400 KB |
15.txt | WA | 65 ms | 6400 KB |
16.txt | WA | 53 ms | 6400 KB |
17.txt | WA | 53 ms | 6400 KB |
18.txt | WA | 65 ms | 6400 KB |
19.txt | WA | 52 ms | 6400 KB |
20.txt | WA | 53 ms | 6400 KB |
21.txt | WA | 74 ms | 6400 KB |
22.txt | WA | 64 ms | 6400 KB |
23.txt | WA | 64 ms | 6400 KB |
24.txt | WA | 74 ms | 6400 KB |
25.txt | WA | 63 ms | 5120 KB |
26.txt | WA | 57 ms | 5120 KB |
27.txt | WA | 75 ms | 5248 KB |
28.txt | WA | 57 ms | 4992 KB |
29.txt | WA | 59 ms | 5760 KB |
30.txt | WA | 69 ms | 5888 KB |
31.txt | AC | 1 ms | 4224 KB |
32.txt | AC | 1 ms | 4224 KB |
33.txt | AC | 1 ms | 4224 KB |
34.txt | AC | 1 ms | 4224 KB |
s1.txt | AC | 1 ms | 4224 KB |
s2.txt | AC | 1 ms | 4224 KB |