QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 512 MB Total points: 100

#7967. 二进制

统计

题目描述

今天也是喜欢二进制串的一天,小 F 开始玩二进制串的游戏。

小 F 给出了一个这里有一个长为 $n$ 的二进制串 $s$,下标从 $1$ 到 $n$,且 $\forall i\in[1,n],s_i\in \{0,1\}$,他想要删除若干二进制子串。

具体的,小 F 做出了 $n$ 次尝试。

在第 $i\in[1,n]$ 次尝试中,他会先写出正整数 $i$ 的二进制串表示 $t$(无前导零,左侧为高位,例如 $10$ 可以写为 $1010$)。

随后找到这个二进制表示 $t$ 在 $s$ 中从左到右 第一次 出现的位置,并删除这个串。

注意,删除后左右部分的串会拼接在一起 形成一个新的串,请注意新串下标的改变。

若当前 $t$ 不在 $s$ 中存在,则小 F 对串 $s$ 不作出改变。

你需要回答每一次尝试中,$t$ 在 $s$ 中第一次出现的位置的左端点以及 $t$ 在 $s$ 中出现了多少次。

定义两次出现不同当且仅当出现的位置的左端点不同。

请注意输入输出效率。

输入格式

第一行一个正整数 $n$($1\leq n\leq 1000000$)。

第二行一个长度为 $n$ 的字符串 $s$。保证 $\forall i\in[1,n], s_i \in \{0, 1\}$。

输出格式

输出共 $n$ 行,每行两个整数,第 $i$ 行表示小 F 进行第 $i$ 次尝试时开头端点的位置以及相应的字符串出现的次数。

若这次尝试失败,则当前行输出 $-1\ 0$。

样例1输入

20
01001101101101110010

样例1输出

2 11
5 5
4 5
11 1
4 2
7 1
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.