QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#10980. K-重复数组

Statistiques

对于一个正整数 $K$,若一个由正整数组成的序列 $V$ 满足以下条件,则称其为 $K$-rep:

  • 存在一个长度为 $K$ 的正整数序列 $B$,使得将 $B$ 重复 $10^{100}$ 次后得到的序列 $B'$ 包含 $V$ 作为其连续子序列。

给定一个长度为 $N$ 的序列 $A = (A_1, A_2, \dots, A_N)$,其中每个元素要么是正整数,要么是 $-1$。对于每个 $K = 1, 2, \dots, N$,请解决以下问题:

  • 判断是否存在一种将 $A$ 中的每个 $-1$ 替换为正整数的方法,使得结果序列是 $K$-rep。

$N$ $A_1 \ A_2 \ \dots \ A_N$

  • 所有输入均为整数。
  • $1 \le N \le 2 \times 10^5$。
  • 对于每个 $i$,满足 $1 \le A_i \le N$ 或 $A_i = -1$。

输出一个长度为 $N$ 的字符串。如果对于 $K = i$ 的情况存在满足条件的替换,则第 $i$ 个字符应为 $1$,否则为 $0$。

样例

输入格式 1

5
1 2 -1 2 1

输出格式 1

01011

说明

在样例中,一种可能的 $A_i = -1$ 的替换方式是序列 $(1, 2, 3, 2, 1)$。对于 $K = 4$,令 $B = (2, 3, 2, 1)$。由于将 $B$ 重复多次后得到的序列 $B'$ 包含 $(1, 2, 3, 2, 1)$ 作为连续子序列,因此 $(1, 2, 3, 2, 1)$ 是 $4$-rep。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.