-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
39 lines (37 loc) · 795 Bytes
/
Copy pathB.cpp
File metadata and controls
39 lines (37 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline int len(const T &a) { return a.size(); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<int> guys(n, -1);
for (int i = 0; i < n; ++i) {
if (!a[i]) {
continue;
}
int to = max((i + 1) - a[i], 0);
guys[to] = max(guys[to], i);
}
set<int> open;
vector<bool> cool(n);
for (int i = 0; i < n; ++i) {
if (guys[i] >= i) {
open.insert(guys[i]);
}
cool[i] = !open.empty() && *open.rbegin() >= i;
}
for (int i = 0; i < n; ++i) {
cout << (cool[i] ? 1 : 0) << ' ';
}
cout << '\n';
}
}