Back to disaster recovery — Lamia now needs to know, for EVERY possible starting machine in the failover network (from Set 12), whether the primary server (node N) is reachable, without re-running the search from scratch each time. Same jump-graph setup as before (from i you can go to i+A[i] or i-A[i]), but now you must answer whether EVERY pair (start, N) is reachable, for start = 1..N, efficiently — precompute reachability to node N for all starting nodes using a SINGLE reverse BFS from node N (think about reversing the edges), rather than running BFS N times.
Input
Line1: N. Line2: N integers (array A).
Output
N characters (or space-separated 1/0): whether node i can reach node N.
Constraints
1 ≤ N ≤ 10^5
Sample Input
5 2 3 1 1 1
Sample Output
1 0 1 1 1
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.