#P11157. 【MX-X6-T3】さよならワンダーランド

【MX-X6-T3】さよならワンダーランド

Background

Original problem link: https://oier.team/problems/X6D


Look, let’s go\\ You held my hand and pulled me along\\ With those beautiful eyes, you said\\ We are just like back then\\ Nothing has changed\\ At least\\ Let the two of us dream together

—— Sayonara Wonderland - Nanatsukaze

Where should we look for the person who can lead you into the dreams of your childhood?

Problem Description

Given a sequence a1,a2,,ana_1, a_2, \dots, a_n, for each integer ii from 11 to nn, find any integer jj such that all of the following conditions hold, or determine that no such jj exists:

  • 1i+jn1 \leq i + j \leq n
  • aijai+ja_i \leq j \leq a_{i+j}

Input Format

The first line contains an integer nn

The next line contains nn space-separated integers a1,a2,,ana_1, a_2, \dots, a_n

Output Format

Output nn lines。

For the ii-th line, if you can find a jj such that 1i+jn1 \leq i + j \leq n and aijai+ja_i \leq j \leq a_{i+j} both hold, first output 11, then output the jj you found, separated by a space. If there are multiple valid jj, you may output any one of them. If no such jj exists, output only 00

3
-1 1 4
1 2
1 1
0
5
1 -1 0 2 -3
0
1 -1
1 0
0
1 -3

Hint

Sample Explanation #1

When i=1,j=2i = 1, j = 2, we have ai=1a_i = -1 and ai+j=4a_{i+j} = 4, satisfying aijai+ja_i \leq j \leq a_{i+j}

When i=2,j=1i = 2, j = 1, we have ai=1a_i = 1 and ai+j=4a_{i+j} = 4, satisfying aijai+ja_i \leq j \leq a_{i+j}

When i=3i = 3, it can be proven that no jj satisfies the conditions。

Constraints

For all testdata, it is guaranteed that 1n3×1051 \leq n \leq 3 \times 10^5 and 109ai109-10^9 \leq a_i \leq 10^9

Bundled tests, with a total of 3 subtasks. The specific limits are as follows:

  • Subtask 1 (17 pts): n1000n \leq 1000
  • Subtask 2 (39 pts): For all 1in1 \leq i \leq n, it is guaranteed that aiia_i \leq -i
  • Subtask 3 (44 pts): No additional constraints。

Translated by ChatGPT 5