{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"两种操作:\n* ``+w`` 表示新增一个单词 $w$;\n* ``?p`` 表示询问有多少个 $p$ 中有多少个子串,满足是之前学过的单词。\n\n字符仅包含 0 和 1,**强制在线**。\n\n多组数据。\n\n---\n \n\u003cdiv class\u003d\"panel_content\"\u003e\n Now Coach Pang is preparing for the Graduate Record Examinations as George did in 2011. At each day, Coach Pang can:\n \u003cbr\u003e\n \u003cb\u003e\"+w\"\u003c/b\u003e: learn a word w\n \u003cbr\u003e\n \u003cb\u003e\"?p\"\u003c/b\u003e: read a paragraph p, and count the number of learnt words. Formally speaking, count the number of substrings of p which is a learnt words.\n \u003cbr\u003e\n Given the records of N days, help Coach Pang to find the count. For convenience, the characters occured in the words and paragraphs are only \u00270\u0027 and \u00271\u0027.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"MD","content":" The first line of the input file contains an integer T, which denotes the number of test cases. T test cases follow.\n\u003cbr\u003e\n The first line of each test case contains an integer N (1 \u0026lt;\u003d N \u0026lt;\u003d 10\u003csup\u003e5\u003c/sup\u003e), which is the number of days. Each of the following N lines contains either \"+w\" or \"?p\". Both p and w are 01-string in this problem.\n\u003cbr\u003e\n Note that the input file has been encrypted. For each string occured, let L be the result of last \"?\" operation. The string given to you has been shifted L times (the shifted version of string s\u003csub\u003e1\u003c/sub\u003es\u003csub\u003e2\u003c/sub\u003e ... s\u003csub\u003ek\u003c/sub\u003e is s\u003csub\u003ek\u003c/sub\u003es\u003csub\u003e1\u003c/sub\u003es\u003csub\u003e2\u003c/sub\u003e ... s\u003csub\u003ek-1\u003c/sub\u003e). You should decrypt the string to the original one before you process it. Note that L equals to 0 at the beginning of each test case.\n\u003cbr\u003e\n The test data guarantees that for each test case, total length of the words does not exceed 10\u003csup\u003e5\u003c/sup\u003e and total length of the paragraphs does not exceed 5 * 10\u003csup\u003e6\u003c/sup\u003e."}},{"title":"Output","value":{"format":"MD","content":" For each test case, first output a line \"Case #x:\", where x is the case number (starting from 1).\n\u003cbr\u003e\n And for each \"?\" operation, output a line containing the result."}},{"title":"Sample","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003e2\n3\n+01\n+01\n?01001\n3\n+01\n?010\n?011\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\n2\nCase #2:\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}