CF1066C Books Queries

题目描述

## 题意描述 ### 您需要维护一个数据结构,支持以下三种操作: * $L$ $id$:在现在序列的左边插一个编号为$id$的物品 * $R$ $id$:在现在序列的右边插一个编号为$id$的物品 * $?$ $id$:查询该点左面有几个元素,右面有几个元素,并取min输出

输入格式

输出格式

说明/提示

Let's take a look at the first example and let's consider queries: 1. The shelf will look like $ [1] $ ; 2. The shelf will look like $ [1, 2] $ ; 3. The shelf will look like $ [1, 2, 3] $ ; 4. The shelf looks like $ [1, \textbf{2}, 3] $ so the answer is $ 1 $ ; 5. The shelf will look like $ [4, 1, 2, 3] $ ; 6. The shelf looks like $ [4, \textbf{1}, 2, 3] $ so the answer is $ 1 $ ; 7. The shelf will look like $ [5, 4, 1, 2, 3] $ ; 8. The shelf looks like $ [5, 4, \textbf{1}, 2, 3] $ so the answer is $ 2 $ . Let's take a look at the second example and let's consider queries: 1. The shelf will look like $ [100] $ ; 2. The shelf will look like $ [100, 100000] $ ; 3. The shelf will look like $ [100, 100000, 123] $ ; 4. The shelf will look like $ [101, 100, 100000, 123] $ ; 5. The shelf looks like $ [101, 100, 100000, \textbf{123}] $ so the answer is $ 0 $ ; 6. The shelf will look like $ [10, 101, 100, 100000, 123] $ ; 7. The shelf will look like $ [10, 101, 100, 100000, 123, 115] $ ; 8. The shelf looks like $ [10, 101, \textbf{100}, 100000, 123, 115] $ so the answer is $ 2 $ ; 9. The shelf will look like $ [10, 101, 100, 100000, 123, 115, 110] $ ; 10. The shelf looks like $ [10, 101, 100, 100000, 123, \textbf{115}, 110] $ so the answer is $ 1 $ .