{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"给定一个字符串,只由 “(”,“)”,“[”,“]”组成\n请你计算出其中合法括号的数目"}},{"title":"Input","value":{"format":"MD","content":"第一行给定一个t (1\u003c\u003d t \u003c\u003d 1000),表示数据组数\n接下来每行给定一个字符串s, (len(s) \u003c\u003d 200000)"}},{"title":"Output","value":{"format":"MD","content":"对于每个字符串输出合法括号的数目"}},{"title":"Example","value":{"format":"MD","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e5\n()\n[]()\n([)]\n)]([\n)[(]\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e1\n2\n2\n0\n1\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"MD","content":"\u003cp\u003eIn the first example you can just erase the whole string.\u003c/p\u003e\n\u003cp\u003eIn the second example you can first erase the brackets on positions $$$1$$$ and $$$2$$$: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003e[]\u003c/span\u003e()\u003c/span\u003e\", then \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()\u003c/span\u003e\" is left. After that you can erase it whole. You could erase the whole string from the beginning but you would get one move instead of two.\u003c/p\u003e\n\u003cp\u003eIn the third example you can first erase the brackets on positions $$$1$$$ and $$$3$$$: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003e(\u003c/span\u003e[\u003cspan class\u003d\"tex-font-style-bf\"\u003e)\u003c/span\u003e]\u003c/span\u003e\". They form an RBS \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()\u003c/span\u003e\". Then \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e[]\u003c/span\u003e\" is left, so you can erase it whole.\u003c/p\u003e\n\u003cp\u003eIn the fourth example there is no subsequence that is an RBS, so you can\u0027t perform a move at all.\u003c/p\u003e\n\u003cp\u003eIn the fifth example you can erase the brackets on positions $$$2$$$ and $$$4$$$: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)\u003cspan class\u003d\"tex-font-style-bf\"\u003e[\u003c/span\u003e(\u003cspan class\u003d\"tex-font-style-bf\"\u003e]\u003c/span\u003e\u003c/span\u003e\" and get \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)(\u003c/span\u003e\" as a result. You can erase nothing from it.\u003c/p\u003e"}}]}