# String Functions in Contiguous Memory Estimated time limit: 0.5 seconds. Memory limit: 128 MB. The actual limit is twice the slowest per-case median time of the standard program on the target judge, rounded up to a multiple of $0.5$ seconds. See the [evaluation notes](../../../docs/评测环境与性能.md). ## Story An old teaching terminal stores several character arrays next to each other. Its maintainer checks each operation: some stay inside their array, some touch a neighboring array, and some must be rejected before execution. (This story was rewritten by GPT-6.) ## Formal Problem Statement There are $n$ arrays indexed $0,\ldots,n-1$ . Array $i$ has length $m_i$ , and every element is $0$ or $1$ . The arrays occupy consecutive memory in index order, without gaps. Define $p_0=0$ , $p_i=\sum_{j