[语言月赛202303] String Problem P

Luogu
IDLGB3726
Time1000ms
Memory512MB
DifficultyP2
2023O2优化字符串(入门)语言月赛
Farmer John 有 $n$ 个字符串,第 $i$ 个字符串为 $s_i$。 现在,你需要支持如下 $q$ 次操作: - `1 x y i`:把字符串 $s_x$ 整体插入到字符串 $s_y$ 的第 $i$ 个字符后,更新 $s_y$。 - `2 y`:求 $s_y$。 例如,设 $s_1 = \texttt{abc}$,$s_2 = \texttt{xyz}$,则执行完 `1 2 1 2` 后(把 $s_2$ 整体插入到 $s_1$ 的第 $2$ 个字符后,更新 $s_1$),$s_1 = \texttt{abxyzc}$,$s_2 = \texttt{xyz}$。 ## Input 第一行是两个整数,表示字符串数量 $n$ 和操作的数量 $q$。 接下来 $n$ 行,每行一个字符串,第 $i$ 行的字符串为 $s_i$。 接下来 $q$ 行,每行四个或二个整数,依次表示每次操作。具体格式见『题目描述』。 ## Output 对每次操作 $2$,输出一行一个字符串,表示被询问的串。 [samples] ## Note ### 数据规模与约定 - 对 $60\%$ 的数据,保证 $i = |s_y|$。 - 对 $100\%$ 的数据,$1 \leq n,q \leq 10$,$1 \leq |s_i| \leq 10$。$1 \leq x, y \leq n$,$1 \leq i \leq |s_y|$。 其中 $|s_y|$ 表示进行对应操作时 $s_y$ 的长度,$|s_i|$ 表示输入时字符串的长度。 provider:一扶苏一
Samples
Input #1
2 2
a
b
1 1 2 1
2 2
Output #1
ba
Input #2
3 6
abc
ijk
xyz
1 2 3 2
1 1 3 5
1 3 1 1
2 1
2 2
2 3
Output #2
axyijkabczbc
ijk
xyijkabcz
API Response (JSON)
{
  "problem": {
    "name": "[语言月赛202303] String Problem P",
    "description": {
      "content": "Farmer John 有 $n$ 个字符串,第 $i$ 个字符串为 $s_i$。 现在,你需要支持如下 $q$ 次操作: - `1 x y i`:把字符串 $s_x$ 整体插入到字符串 $s_y$ 的第 $i$ 个字符后,更新 $s_y$。 - `2 y`:求 $s_y$。 例如,设 $s_1 = \\texttt{abc}$,$s_2 = \\texttt{xyz}$,则执行完 `1 2 1",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB3726"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Farmer John 有 $n$ 个字符串,第 $i$ 个字符串为 $s_i$。\n\n现在,你需要支持如下 $q$ 次操作:\n\n- `1 x y i`:把字符串 $s_x$ 整体插入到字符串 $s_y$ 的第 $i$ 个字符后,更新 $s_y$。\n- `2 y`:求 $s_y$。\n\n例如,设 $s_1 = \\texttt{abc}$,$s_2 = \\texttt{xyz}$,则执行完 `1 2 1...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments