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

    ID: 12442 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>数学Special Judge梦熊比赛

【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:

  • 1≤i+j≤n1 \leq i + j \leq n;
  • ai≤j≤ai+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 1≤i+j≤n1 \leq i + j \leq n and ai≤j≤ai+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 ai≤j≤ai+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 ai≤j≤ai+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 1≤n≤3×1051 \leq n \leq 3 \times 10^5 and −109≤ai≤109-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): n≤1000n \leq 1000。
  • Subtask 2 (39 pts): For all 1≤i≤n1 \leq i \leq n, it is guaranteed that ai≤−ia_i \leq -i。
  • Subtask 3 (44 pts): No additional constraints。

Translated by ChatGPT 5