经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

括号

📝 题解 🔵 仅限 C++
题目描述
<span style="font-size:14px;"></span><span style="font-size:14px;">S1,S2…S2N是一个很好的括号。有两种不同的方式编码:</span> <p style="margin-left:0cm;"> <span style="font-size:14px;">有一个整数序列P1、P2&nbsp;,P&nbsp;=…PN,其中 Pi&nbsp; 是 S 的第 i 个右括号前面的左括号个数。。</span> </p> <p style="margin-left:0cm;"> <span style="font-size:14px;">有一个整数序列W =&nbsp;W1,W2…WN,对于 S 中的某一个右括号 a,Wi 是从与 a 匹配的左括号开始数起,数到</span> </p> <p style="margin-left:0cm;"> <span style="font-size:14px;">&nbsp;a 为止的右括号个数。</span> </p> <p style="margin-left:0cm;"> <span style="font-size:14px;">以下是上述编码的一个例子:</span> </p> <p style="margin-left:0cm;"> <span style="font-size:14px;">S(((()()())))</span> </p> <p style="margin-left:0cm;"> <span style="font-size:14px;">序列 </span><span style="font-size:14px;">4 5 6 6 6 6</span> </p> <p style="margin-left:0cm;"> <span style="font-size:14px;">&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;1&nbsp;1 4 5 6</span> </p> <p style="margin-left:0cm;"> <span style="font-size:14px;">写一个程序来转换编码</span> </p> <span style="font-size:14px;"></span>
输入格式
<p style="margin-left:0cm;background:white;"> <span style="font-size:14px;">输入的第一行包含一个整数T(1≤t≤10),为测试用例的数量,每个测试案例的第一行是一个整数N(1 &lt; =</span> </p> <p style="margin-left:0cm;background:white;"> <span style="font-size:14px;">&nbsp;n≤20),第二行是一个P字符串序列包含n个正整数,中间用空格隔开。</span> </p>
输出格式
<span style="font-size:14px;"></span><span style="font-size:14px;line-height:1.5;background-color:white;">对于每一个测试案例,输出行包含N个整数描述对应给定字符串的W序列。中间用空格隔开。</span><span style="font-size:14px;"><br /> </span>
样例
样例输入 1
2 6 4 5 6 6 6 6 9 4 6 6 6 6 8 9 9 9
样例输出 1
1 1 1 4 5 6 1 1 2 4 5 1 1 3 9
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用