Submission #1843431
Source Code Expand
#include <cstdio> #include <iostream> inline int Get() { char ch; int Num, Sign = 0; while ((ch = getchar()) < '0' || ch > '9') if (ch == '-') Sign ^= 1; Num = ch - '0'; while ((ch = getchar()) >= '0' && ch <= '9') Num = (Num << 3) + (Num << 1) + ch - '0'; return Sign ? -Num : Num; } const int N = 2e5 + 5; int n, m, pos[N], a[20], len, toL[20][N], toR[20][N]; int all, preL[1 << 20], preR[1 << 20], flag[N]; inline int queryL(int x) { int l = 1, r = n, res = 1; while (l <= r) { int mid = l + r >> 1; if (toL[len][mid] <= x) res = mid, l = mid + 1; else r = mid - 1; } return res; } inline int queryR(int x) { int l = 1, r = n, res = 1; while (l <= r) { int mid = l + r >> 1; if (toR[len][mid] >= x) res = mid, r = mid - 1; else l = mid + 1; } return res; } int main() { n = Get(), m = Get(); for (int i = 1; i <= n; ++i) pos[i] = Get(); for (int x = m; x; x >>= 1) a[len++] = x >> 1; a[len] = m; for (int k = 0; k <= len; ++k) { toL[k][1] = 1; for (int i = 2; i <= n; ++i) toL[k][i] = (pos[i] - pos[i - 1] <= a[k]) ? toL[k][i - 1] : i; toR[k][n] = n; for (int i = n - 1; i; --i) toR[k][i] = (pos[i + 1] - pos[i] <= a[k]) ? toR[k][i + 1] : i; } all = 1 << len; for (int opt = 0; opt < all; ++opt) preL[opt] = 0; for (int opt = 1; opt < all; ++opt) for (int k = 0; k < len; ++k) if (opt & (1 << k)) { int nxt = opt ^ (1 << k); preL[opt] = std :: max(preL[opt], preL[nxt]); if (preL[nxt] < n) preL[opt] = std :: max(preL[opt], toR[k][preL[nxt] + 1]); } for (int opt = 0; opt < all; ++opt) preR[opt] = n + 1; for (int opt = 1; opt < all; ++opt) for (int k = 0; k < len; ++k) if (opt & (1 << k)) { int nxt = opt ^ (1 << k); preR[opt] = std :: min(preR[opt], preR[nxt]); if (preR[nxt] > 1) preR[opt] = std :: min(preR[opt], toL[k][preR[nxt] - 1]); } for (int opt = 0; opt < all; ++opt) { int x = queryR(preR[(all - 1) ^ opt] - 1), y = queryL(preL[opt] + 1); if (x <= y) ++flag[x], --flag[y + 1]; } for (int i = 1; i <= n; ++i) flag[i] += flag[i - 1], puts(flag[i] ? "Possible" : "Impossible"); }
Submission Info
Submission Time | |
---|---|
Task | E - Camel and Oases |
User | wy1627 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 2184 Byte |
Status | AC |
Exec Time | 96 ms |
Memory | 39040 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 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, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 3 ms | 10496 KB |
00_example_02.txt | AC | 3 ms | 10496 KB |
00_example_03.txt | AC | 4 ms | 14592 KB |
01.txt | AC | 55 ms | 36096 KB |
02.txt | AC | 18 ms | 33280 KB |
03.txt | AC | 55 ms | 36096 KB |
04.txt | AC | 18 ms | 33280 KB |
05.txt | AC | 53 ms | 36096 KB |
06.txt | AC | 64 ms | 36480 KB |
07.txt | AC | 22 ms | 33536 KB |
08.txt | AC | 62 ms | 36352 KB |
09.txt | AC | 22 ms | 33536 KB |
10.txt | AC | 59 ms | 36224 KB |
11.txt | AC | 35 ms | 33920 KB |
12.txt | AC | 60 ms | 36224 KB |
13.txt | AC | 94 ms | 39040 KB |
14.txt | AC | 53 ms | 36096 KB |
15.txt | AC | 18 ms | 33280 KB |
16.txt | AC | 53 ms | 36096 KB |
17.txt | AC | 18 ms | 33280 KB |
18.txt | AC | 52 ms | 36096 KB |
19.txt | AC | 29 ms | 33536 KB |
20.txt | AC | 63 ms | 36480 KB |
21.txt | AC | 22 ms | 33536 KB |
22.txt | AC | 62 ms | 36480 KB |
23.txt | AC | 23 ms | 33664 KB |
24.txt | AC | 60 ms | 36224 KB |
25.txt | AC | 35 ms | 33792 KB |
26.txt | AC | 62 ms | 36352 KB |
27.txt | AC | 95 ms | 39040 KB |
28.txt | AC | 63 ms | 36480 KB |
29.txt | AC | 22 ms | 33536 KB |
30.txt | AC | 63 ms | 36480 KB |
31.txt | AC | 34 ms | 33792 KB |
32.txt | AC | 59 ms | 36224 KB |
33.txt | AC | 35 ms | 33792 KB |
34.txt | AC | 61 ms | 36352 KB |
35.txt | AC | 96 ms | 39040 KB |
36.txt | AC | 53 ms | 36096 KB |
37.txt | AC | 18 ms | 33280 KB |
38.txt | AC | 53 ms | 36096 KB |
39.txt | AC | 18 ms | 33280 KB |
40.txt | AC | 53 ms | 36096 KB |
41.txt | AC | 29 ms | 33536 KB |
42.txt | AC | 53 ms | 36096 KB |
43.txt | AC | 29 ms | 33536 KB |
44.txt | AC | 53 ms | 36096 KB |
45.txt | AC | 29 ms | 33536 KB |
46.txt | AC | 22 ms | 33536 KB |
47.txt | AC | 61 ms | 36352 KB |
48.txt | AC | 34 ms | 33792 KB |
49.txt | AC | 61 ms | 36352 KB |
50.txt | AC | 34 ms | 33792 KB |
51.txt | AC | 61 ms | 36352 KB |
52.txt | AC | 35 ms | 33792 KB |
53.txt | AC | 61 ms | 36352 KB |
54.txt | AC | 34 ms | 33792 KB |
55.txt | AC | 62 ms | 36352 KB |
56.txt | AC | 21 ms | 33408 KB |
57.txt | AC | 62 ms | 36352 KB |
58.txt | AC | 34 ms | 33792 KB |
59.txt | AC | 60 ms | 36224 KB |
60.txt | AC | 35 ms | 33792 KB |
61.txt | AC | 61 ms | 36352 KB |
62.txt | AC | 35 ms | 33792 KB |
63.txt | AC | 61 ms | 36352 KB |
64.txt | AC | 35 ms | 33792 KB |
65.txt | AC | 61 ms | 36352 KB |
66.txt | AC | 3 ms | 10496 KB |
67.txt | AC | 3 ms | 10496 KB |