{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eMaintain two sets of strings \u003cb\u003eS\u003c/b\u003e and \u003cb\u003eT\u003c/b\u003e. Initially, each set contains an empty string with id 1.\u003c/p\u003e\r\n\u003cp\u003e\r\nYour program are to perform the following four operations:\r\n\u003c/p\u003e\r\n\u003col\u003e\r\n \u003cli\u003eAdd a char \u003cb\u003ec\u003c/b\u003e to the end of an existed string \u003cb\u003eSi\u003c/b\u003e in \u003cb\u003eS\u003c/b\u003e, then insert the new string into \u003cb\u003eS\u003c/b\u003e. Since there has been \u003cb\u003en\u003c/b\u003e strings in \u003cb\u003eS\u003c/b\u003e already, the new string will hold the id \u003cb\u003en+1\u003c/b\u003e.\u003c/li\u003e\r\n \u003cli\u003eAdd a char \u003cb\u003ec\u003c/b\u003e to the beginning or to the end of an existed string \u003cb\u003eTi\u003c/b\u003e in \u003cb\u003eT\u003c/b\u003e, then insert the new string into \u003cb\u003eT\u003c/b\u003e.\u003c/li\u003e\r\n \u003cli\u003eChoose two existed strings \u003cb\u003eTi\u003c/b\u003e and \u003cb\u003eTj\u003c/b\u003e from \u003cb\u003eT\u003c/b\u003e, next combine them into a new one \u003cb\u003eTiTj\u003c/b\u003e, then insert the new string into \u003cb\u003eT\u003c/b\u003e.\u003c/li\u003e\r\n \u003cli\u003ePrint the time that an existed string \u003cb\u003eTi\u003c/b\u003e in \u003cb\u003eT\u003c/b\u003e appears in an string \u003cb\u003eSi\u003c/b\u003e in \u003cb\u003eS\u003c/b\u003e. Your program should print \u003ctt\u003e0\u003c/tt\u003e if \u003cb\u003eTi\u003c/b\u003e is an empty string.\u003c/li\u003e\r\n\u003c/ol\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eIn the first line, there is an integer \u003cb\u003eQ\u003c/b\u003e, which means the number of operations to perform.\u003c/p\u003e\r\n\u003cp\u003eIn the next \u003cb\u003eQ\u003c/b\u003e lines,the \u003cb\u003ei\u003c/b\u003e-th line describes the \u003cb\u003ei\u003c/b\u003e-th operation containing some integers. Such a line may look like this:\u003c/p\u003e\u003cp\u003e\r\n\u003c/p\u003e\u003cul\u003e\r\n \u003cli\u003e\u003ctt\u003e1 Si c\u003c/tt\u003e\u003c/li\u003e\r\n \u003cli\u003e\u003ctt\u003e2 0 Ti c\u003c/tt\u003e \u003d\u0026gt; add \u003cb\u003ec\u003c/b\u003e to the beginning of \u003cb\u003eTi\u003c/b\u003e\u003c/li\u003e\r\n \u003cli\u003e\u003ctt\u003e2 1 Ti c\u003c/tt\u003e \u003d\u0026gt; add \u003cb\u003ec\u003c/b\u003e to the end of \u003cb\u003eTi\u003c/b\u003e\u003c/li\u003e\r\n \u003cli\u003e\u003ctt\u003e3 Ti Tj\u003c/tt\u003e\u003c/li\u003e\r\n \u003cli\u003e\u003ctt\u003e4 Ti Si\u003c/tt\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003e\u003cb\u003eQ\u003c/b\u003e \u0026lt;\u003d 300000, \u0027a\u0027 \u0026lt;\u003d \u003cb\u003ec\u003c/b\u003e \u0026lt;\u003d \u0027z\u0027\u003c/p\u003e\r\n\r\n\u003cp\u003eThe number of the first operation will not exceed 100000.\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003eThe number of the third operation will not exceed 30000.\u003c/p\u003e\r\n\u003cp\u003eThe number of fourth operation will not exceed 100000.\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each \u003ctt\u003e\"4 Ti Si\"\u003c/tt\u003e operation, print its result.\u003c/p\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e18\r\n1 1 a\r\n1 2 a\r\n1 3 b\r\n1 2 b\r\n1 5 a\r\n1 5 b\r\n2 1 1 a\r\n3 2 2\r\n2 0 3 b\r\n2 1 2 b\r\n3 2 5\r\n3 5 2\r\n4 7 6\r\n4 5 6\r\n4 3 4\r\n4 2 4\r\n4 2 7\r\n4 2 6\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n1\r\n1\r\n2\r\n1\r\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}