306359: CF1184D1. Parallel Universes (Easy)

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Parallel Universes (Easy)

题意翻译

**题目描述** Third Doctor 曾说平行宇宙之间的旅行“就像穿越旅行”。然而,他错认为存在着无限的平行宇宙,而事实上它们永远不会超过$250$个。 海蒂最近得到了一个多元宇宙观测器。她能看到所有的$N$个宇宙排成一排,它们之间不存在联系。 Doctor 在第$k$宇宙。 由于时空的种种原因,宇宙的数量永远不会超过$m$。 显然,多元宇宙变幻莫测,每次做出变化时,必将会有一个新的并行宇宙被创建,或者一个不存在的链接被破坏。 更具体地说, - 当一个宇宙被创造时,它将在任何两个相邻的宇宙之间或在其中一个末端出现。 - 当一个连接断开时,它可以在任何两个相邻的宇宙之间被切断。在将多宇宙分割成两段之后,不包含 Doctor 的部分将在时空中陨落,不复存在。 海蒂突发奇想,模拟$t$个变化。每次变化时时,海蒂想知道多元宇宙的长度(即宇宙的数量)和 Doctor 的位置。 **输入格式** 第一行包含四个整数$n$,$k$,$m$和$t$,意义如上所示。 以下$t$行,每行包含一个$0$或$1$的数和$i$。 若第一个数为$0$,意为在位置$i$($1\leq i\leq l+1$)插入一个宇宙,其中$l$表示多重宇宙的当前长度。 若第一个数为$1$,表示第i个链接断开了($1\leq i\leq l-1$),其中$l$表示多元宇宙的当前长度。 **输出格式** 输出共$t$行,每行包含两个整数$l$和$k$,分别表示多元宇宙的当前长度和 Doctor 当前位置。 数据保证多重宇宙的长度最多为$m$,并且当断开连接时,多重宇宙中至少有一个宇宙。

题目描述

The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than 250. Heidi recently got her hands on a multiverse observation tool. She was able to see all $ n $ universes lined up in a row, with non-existent links between them. She also noticed that the Doctor was in the $ k $ -th universe. The tool also points out that due to restrictions originating from the space-time discontinuum, the number of universes will never exceed $ m $ . Obviously, the multiverse is unstable because of free will. Each time a decision is made, one of two events will randomly happen: a new parallel universe is created, or a non-existent link is broken. More specifically, - When a universe is created, it will manifest itself between any two adjacent universes or at one of the ends. - When a link is broken, it could be cut between any two adjacent universes. After separating the multiverse into two segments, the segment NOT containing the Doctor will cease to exist. Heidi wants to perform a simulation of $ t $ decisions. Each time a decision is made, Heidi wants to know the length of the multiverse (i.e. the number of universes), and the position of the Doctor.

输入输出格式

输入格式


The first line contains four integers $ n $ , $ k $ , $ m $ and $ t $ ( $ 2 \le k \le n \le m \le 250 $ , $ 1 \le t \le 1000 $ ). Each of the following $ t $ lines is in one of the following formats: - " $ 1 $ $ i $ " — meaning that a universe is inserted at the position $ i $ ( $ 1 \le i \le l + 1 $ ), where $ l $ denotes the current length of the multiverse. - " $ 0 $ $ i $ " — meaning that the $ i $ -th link is broken ( $ 1 \le i \le l - 1 $ ), where $ l $ denotes the current length of the multiverse.

输出格式


Output $ t $ lines. Each line should contain $ l $ , the current length of the multiverse and $ k $ , the current position of the Doctor. It is guaranteed that the sequence of the steps will be valid, i.e. the multiverse will have length at most $ m $ and when the link breaking is performed, there will be at least one universe in the multiverse.

输入输出样例

输入样例 #1

5 2 10 4
0 1
1 1
0 4
1 2

输出样例 #1

4 1
5 2
4 2
5 3

说明

The multiverse initially consisted of 5 universes, with the Doctor being in the second. First, link 1 was broken, leaving the multiverse with 4 universes, and the Doctor in the first. Then, a universe was added to the leftmost end of the multiverse, increasing the multiverse length to 5, and the Doctor was then in the second universe. Then, the rightmost link was broken. Finally, a universe was added between the first and the second universe.

Input

题意翻译

**题目描述** Third Doctor 曾说平行宇宙之间的旅行“就像穿越旅行”。然而,他错认为存在着无限的平行宇宙,而事实上它们永远不会超过$250$个。 海蒂最近得到了一个多元宇宙观测器。她能看到所有的$N$个宇宙排成一排,它们之间不存在联系。 Doctor 在第$k$宇宙。 由于时空的种种原因,宇宙的数量永远不会超过$m$。 显然,多元宇宙变幻莫测,每次做出变化时,必将会有一个新的并行宇宙被创建,或者一个不存在的链接被破坏。 更具体地说, - 当一个宇宙被创造时,它将在任何两个相邻的宇宙之间或在其中一个末端出现。 - 当一个连接断开时,它可以在任何两个相邻的宇宙之间被切断。在将多宇宙分割成两段之后,不包含 Doctor 的部分将在时空中陨落,不复存在。 海蒂突发奇想,模拟$t$个变化。每次变化时时,海蒂想知道多元宇宙的长度(即宇宙的数量)和 Doctor 的位置。 **输入格式** 第一行包含四个整数$n$,$k$,$m$和$t$,意义如上所示。 以下$t$行,每行包含一个$0$或$1$的数和$i$。 若第一个数为$0$,意为在位置$i$($1\leq i\leq l+1$)插入一个宇宙,其中$l$表示多重宇宙的当前长度。 若第一个数为$1$,表示第i个链接断开了($1\leq i\leq l-1$),其中$l$表示多元宇宙的当前长度。 **输出格式** 输出共$t$行,每行包含两个整数$l$和$k$,分别表示多元宇宙的当前长度和 Doctor 当前位置。 数据保证多重宇宙的长度最多为$m$,并且当断开连接时,多重宇宙中至少有一个宇宙。

加入题单

算法标签: