Submission #3244721
Source Code Expand
#include <algorithm> #include <cassert> #include <cstring> #include <iostream> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define TRACE(x) cout << #x << " = " << x << endl #define _ << " _ " << typedef long long llint; const int MAX = 200200; const int MAXK = 20; int a[MAX]; int l[MAX][MAXK], r[MAX][MAXK]; int fl[1 << MAXK], fr[1 << MAXK]; int main(void) { ios_base::sync_with_stdio(false); int N, V; cin >> N >> V; REP(i, N) cin >> a[i]; int K = 0; int v[MAXK]; while (V > 0) { v[K++] = V; V /= 2; } v[K++] = 0; REP(i, N) { REP(j, K) { if (i > 0 && a[i] - a[i - 1] <= v[j]) { l[i][j] = l[i - 1][j]; } else { l[i][j] = i; } } } for (int i = N - 1; i >= 0; --i) { REP(j, K) { if (i < N - 1 && a[i + 1] - a[i] <= v[j]) { r[i][j] = r[i + 1][j]; } else { r[i][j] = i; } } } REP(s, 1 << K) fl[s] = 0, fr[s] = N - 1; REP(s, 1 << K) { REP(j, K) { if (!(s & (1 << j))) { int ns = s | (1 << j); int nfl = fl[s] == N ? N : r[fl[s]][j] + 1; fl[ns] = max(fl[ns], nfl); int nfr = fr[s] == -1 ? -1 : l[fr[s]][j] - 1; fr[ns] = min(fr[ns], nfr); } } } REP(i, N) { bool can = false; int all = (1 << K) - 1 - 1; REP(s, 1 << K) { if ((s & all) == s) { if (fl[s] >= l[i][0] && fr[all ^ s] <= r[i][0]) { can = true; break; } } } if (can) { cout << "Possible\n"; } else { cout << "Impossible\n"; } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Camel and Oases |
User | ikatanic |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1753 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 40576 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 2 ms | 6400 KB |
00_example_02.txt | AC | 2 ms | 6400 KB |
00_example_03.txt | AC | 2 ms | 6400 KB |
01.txt | AC | 295 ms | 12544 KB |
02.txt | AC | 48 ms | 6912 KB |
03.txt | AC | 165 ms | 12544 KB |
04.txt | AC | 57 ms | 6912 KB |
05.txt | AC | 110 ms | 12544 KB |
06.txt | TLE | 2103 ms | 16768 KB |
07.txt | AC | 1986 ms | 9216 KB |
08.txt | TLE | 2103 ms | 14720 KB |
09.txt | TLE | 2103 ms | 9216 KB |
10.txt | TLE | 2103 ms | 14720 KB |
11.txt | TLE | 2103 ms | 9600 KB |
12.txt | TLE | 2103 ms | 14720 KB |
13.txt | TLE | 2103 ms | 40576 KB |
14.txt | AC | 93 ms | 12544 KB |
15.txt | AC | 20 ms | 6912 KB |
16.txt | AC | 79 ms | 12544 KB |
17.txt | AC | 14 ms | 6912 KB |
18.txt | AC | 52 ms | 12544 KB |
19.txt | AC | 44 ms | 7424 KB |
20.txt | TLE | 2103 ms | 16768 KB |
21.txt | AC | 1435 ms | 9216 KB |
22.txt | TLE | 2103 ms | 14720 KB |
23.txt | TLE | 2043 ms | 9344 KB |
24.txt | AC | 61 ms | 14720 KB |
25.txt | TLE | 2103 ms | 9600 KB |
26.txt | TLE | 2103 ms | 14720 KB |
27.txt | TLE | 2103 ms | 40576 KB |
28.txt | TLE | 2103 ms | 14720 KB |
29.txt | TLE | 2103 ms | 9216 KB |
30.txt | TLE | 2103 ms | 14720 KB |
31.txt | TLE | 2005 ms | 9728 KB |
32.txt | TLE | 2103 ms | 14720 KB |
33.txt | TLE | 2103 ms | 9600 KB |
34.txt | TLE | 2103 ms | 14720 KB |
35.txt | TLE | 2103 ms | 40576 KB |
36.txt | AC | 84 ms | 12544 KB |
37.txt | AC | 21 ms | 6912 KB |
38.txt | AC | 78 ms | 12544 KB |
39.txt | AC | 22 ms | 6912 KB |
40.txt | AC | 53 ms | 12544 KB |
41.txt | AC | 42 ms | 7424 KB |
42.txt | AC | 53 ms | 12544 KB |
43.txt | AC | 43 ms | 7424 KB |
44.txt | AC | 80 ms | 12544 KB |
45.txt | AC | 30 ms | 7424 KB |
46.txt | AC | 975 ms | 9216 KB |
47.txt | TLE | 2103 ms | 14720 KB |
48.txt | TLE | 2103 ms | 9600 KB |
49.txt | AC | 1583 ms | 14848 KB |
50.txt | TLE | 2103 ms | 9600 KB |
51.txt | TLE | 2103 ms | 14720 KB |
52.txt | TLE | 2103 ms | 9600 KB |
53.txt | TLE | 2103 ms | 14720 KB |
54.txt | TLE | 2103 ms | 9600 KB |
55.txt | TLE | 2103 ms | 14720 KB |
56.txt | AC | 544 ms | 9088 KB |
57.txt | AC | 117 ms | 14848 KB |
58.txt | TLE | 2103 ms | 9600 KB |
59.txt | AC | 222 ms | 14720 KB |
60.txt | TLE | 2103 ms | 9600 KB |
61.txt | TLE | 2103 ms | 14720 KB |
62.txt | TLE | 2103 ms | 9600 KB |
63.txt | TLE | 2103 ms | 14720 KB |
64.txt | TLE | 2103 ms | 9600 KB |
65.txt | TLE | 2103 ms | 14720 KB |
66.txt | AC | 2 ms | 6400 KB |
67.txt | AC | 2 ms | 6400 KB |