{"problem":{"name":"L. Queries on a String","description":{"content":"A string s is given. Also there is a string p, and initially it is empty. You need to perform q operations of kind «add a letter to the end of the string p» and «remove a letter from the end of the st","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10175L"},"statements":[{"statement_type":"Markdown","content":"A string s is given. Also there is a string p, and initially it is empty. You need to perform q operations of kind «add a letter to the end of the string p» and «remove a letter from the end of the string p», and after performing each operation you must say whether or not s contains p as a subsequence.\n\nThe first line contains the string s of length from 1 to 200000, consisting of lowercase Latin letters.\n\nThe second line contains a single integer q (1 ≤ q ≤ 200000) — the number of operations.\n\nEach of the next q lines describes an operation in the format «_push c_», which means «add letter c to the end of the string p» (c is lowercase Latin letter), or «_pop_», which means «remove letter from the end of the string p». The «_pop_» operations is guaranteed never to be applied to the empty string p.\n\nOutput q lines, each of which equals «_YES_» or «_NO_», depending on whether or not the string p is contained in the string s as a subsequence after performing the corresponding operation.\n\n## Input\n\nThe first line contains the string s of length from 1 to 200000, consisting of lowercase Latin letters.The second line contains a single integer q (1 ≤ q ≤ 200000) — the number of operations.Each of the next q lines describes an operation in the format «_push c_», which means «add letter c to the end of the string p» (c is lowercase Latin letter), or «_pop_», which means «remove letter from the end of the string p». The «_pop_» operations is guaranteed never to be applied to the empty string p.\n\n## Output\n\nOutput q lines, each of which equals «_YES_» or «_NO_», depending on whether or not the string p is contained in the string s as a subsequence after performing the corresponding operation.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ s \\in \\Sigma^* $ be a fixed string of length $ n $, where $ \\Sigma $ is the set of lowercase Latin letters.  \nLet $ p \\in \\Sigma^* $ be a dynamic string, initially empty.  \nLet $ Q = (o_1, o_2, \\dots, o_q) $ be a sequence of $ q $ operations, where each $ o_i \\in \\{ \\texttt{push}(c), \\texttt{pop} \\} $, $ c \\in \\Sigma $.  \n\n**Constraints**  \n1. $ 1 \\leq |s| \\leq 200000 $  \n2. $ 1 \\leq q \\leq 200000 $  \n3. Each `pop` operation is applied only when $ p \\neq \\varepsilon $.  \n4. All characters in $ s $ and operations are lowercase Latin letters.  \n\n**Objective**  \nAfter each operation $ o_i $, update $ p $ accordingly and determine whether $ p $ is a subsequence of $ s $.  \nOutput \"YES\" if $ p \\sqsubseteq s $, otherwise \"NO\".  \n\nFormally, for each $ i \\in \\{1, \\dots, q\\} $:  \n- If $ o_i = \\texttt{push}(c) $, then $ p \\leftarrow p \\cdot c $  \n- If $ o_i = \\texttt{pop} $, then $ p \\leftarrow p[1..|p|-1] $  \nThen output $ \\texttt{YES} $ if $ p $ is a subsequence of $ s $, else $ \\texttt{NO} $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10175L","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}