Parencodings(简单模拟法)

LVGL 蜂巢气泡菜单(Hex Menu) h。 阅读详情

链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22007#problem/A

G - Parencodings

Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u

Submit

Status

Description

Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways:

q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith right parenthesis in S (P-sequence).

q By an integer sequence W = w1 w2...wn where for each right parenthesis, say a in S, we associate an integer which is the number of right parentheses counting from the matched left parenthesis of a up to a. (W-sequence).

Following is an example of the above encodings:

S (((()()())))

P-sequence     4 5 6666

W-sequence     1 1 1456

Write a program to convert P-sequence of a well-formed string to the W-sequence of the same string.

Input

The first line of the input contains a single integer t (1 <= t <= 10), the number of test cases, followed by the input data for each test case. The first line of each test case is an integer n (1 <= n <= 20), and the second line is the P-sequence of a well-formed string. It contains n positive integers, separated with blanks, representing the P-sequence.

Output

The output file consists of exactly t lines corresponding to test cases. For each test case, the output line should contain n integers describing the W-sequence of the string corresponding to its given P-sequence.

Sample Input

2

6

4 5 6 6 6 6

9

4 6 6 6 6 8 9 9 9

Sample Output

1 1 1 4 5 6

1 1 2 4 5 1 1 3 9

Memory Time Language Length

176 KB 0 ms C++ 1212 B

/*题意给出一个数列表示,每个右括号前面有几个几个左括号

求每个右括号与它的最近匹配的那个左括号要经过几个左括号

方法:简单模拟法:采用首先还原原数列

其次一一查找即可

*/


#include<stdio.h>
#include<string.h>
#include <iostream>
using namespace std;
int main()
{ int p[50];
int s[25],w[25];
int T,n,i,j,k,c;
scanf("%d",&T);
while(T--)
 {
           scanf("%d",&n);
           for(i=1;i<=n;i++)
           scanf("%d",&s[i]);
           memset(p,0,sizeof(p));
           memset(w,0,sizeof(w));
           k=1;
           s[0]=0;
           for(i=1;i<=n;i++)
           {
              for(j=0;j<s[i]-s[i-1];j++)
              p[k++]=1;
              k++;
           }
           c=1;
           for(i=1;i<k;i++)
             if(p[i]==0)
             {
                      for(j=i-1;j>=1;j--)
                      if(p[j]!=0)
                      {w[c]++;
                      if(p[j]==1)
                       {
                                 p[j]=-1;
                                 c++;
                                 break;
                       }
                      }
             }
           for(i=1;i<c-1;i++)
           printf("%d ",w[i]);
           printf("%d\n",w[c-1]);
 }
       return 0;
}


uniapp - 使用web-view加载本地网页vue页面,用webview导入本地网页,uniAPP中使用web-view加载的本地及远程vue页面+双向通讯功能(兼容微信小程序、安卓苹果APP) uniapp的App端web-view加载本地html,uniapp微信小程序webview加载本地HTML文件,在uniAPP中使用web-view加载的本地及远程vue页面且进行双向通讯,uni-app的web-view组件,支持加载远程网页,在app环境下,还支持加载本地HTML页面。uniapp WebView组件实现本地网页加载与通讯传值,uniAPP如何内嵌webView引入本地的vue网页示例代码,uniapp在web-view加载的本地及远程HTML中调用uni的API及网页和vue页面跳转 阅读详情

相关推荐

Matlab双目相机标定

1 概述 现在有许多双目相机在出厂时就已经标定好了,用户拿到手后可以直接使用,例如Intel Realsense系列。但是有些相机出厂的时候并没有完成标定工作,因而这个时候就需要我们自己来标定。由于笔者曾改装过一个双目相机,最远可以测至50m,因此有一定的心得体会想给大家分享一下。本文主要介绍双目相机标定的整个过程,以及导出标定数据的方法。 相机标定主要分为手动标定和自动标定,手动标定比较繁琐,这里主要介绍基于matlab工具箱的自动标定方式来对双目相机进行标定。具体的相关标定细节也可以参照这篇博客:m

weixin_46133643的博客 2万+

1068:Parencodings

栈,括号匹配 解题思路: 根据P串还原出括号串:第一个数是4,说明第一个右括号前有4个左括号;第二个数是5,说明到一个右括号后,有5-4个左括号,依次类推,还原出括号串。 用栈来匹配括号:很容易发现,中间包含多少个括号对,可以直接用左括号和右括号的下标来计算。因此,碰到左括号时,把其下标压入栈,碰到右括号时,出栈,由两个下标计算出结果。 参考:https://blog.csdn.net/xp731574722/article/details/76566171 //栈,括号匹配 #include <

weixin_49403900的博客 215

资源描述框架RDF及Turtle

文章目录1. RDF1.1 简介1.2 格式1.3 RDF的要求2. Turtle2.1 语法2.1.1 简单三元组2.1.2 Turtle中的命名空间2.1.3 Base URI2.1.4 谓语列表2.1.5 宾语列表2.1.6 空白节点(bNodes)2.1.7 数据类型2.1.8 Class membership2.1.9 空URI2.1.10 集合 1. RDF 1.1 简介 RDF(Resource Description Framework)语义网的标准数据模型,是一个用于描述 Web 上的资

doublewhite233的博客 2498

Parencodings

ParencodingsTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 134    Accepted Submission(s): 89Problem DescriptionLet S = s1 s2 … s2n be a w

Rachel Zhang的专栏 2546

ZYNQ-7035+HMCAD1511高速数据采集系统设计

高速数据采集是电子测量、雷达信号处理与通信基带验证的核心技术基础,其性能瓶颈常集中于采样率、通道同步性与实时处理能力。基于ADC采样原理与SoC异构架构,高带宽、低抖动时钟链路与FPGA+ARM协同处理成为突破关键。ZYNQ-7035凭借275K逻辑单元与千级DSP资源,显著提升LVDS数据流吞吐与片上滤波/触发等实时算法部署能力;HMCAD1511则以1GSPS四通道同步采样和8位分辨率,满足示波器级动态范围需求。该组合广泛应用于嵌入式信号采集平台开发、教学实验系统构建及国产化仪器原型验证。

weixin_28939623的博客 265

量化实战:用三种波动率模型给你的期货策略做个“体检”(附Python代码与螺纹钢案例)

本文深入探讨了三种专业波动率模型(Parkinson、Garman-Klass和Rogers-Satchell)在期货量化策略中的应用,并以螺纹钢期货为例,展示了如何通过Python实现这些模型进行多维度波动率分析。文章详细比较了不同模型的特点和适用场景,提供了动态仓位管理、止损策略优化等实战应用方案,帮助交易者更精准地评估市场风险,优化策略表现。

weixin_26824299的博客 465

:Parencodings

Parencodings D1075:Parencodings 时间限制: 1000ms内存限制: 65536kB 描述Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P =

代码全集 639

集成电路模拟版图入门-版图基础学习笔记(一)

集成电路设计模拟版图入门笔记,了解版图的定义、意义、工具、设计流程。认识版图及版图组成的两大部件,版图编辑器有哪些,电路图编辑器,了解工艺厂商等。

weixin_52955333的博客 2万+

Parencodings--POJ 1068

1、题目类型:模拟题。 2、解题思路:(1)根据输入数据建立Arr[],0表示'(',1表示')';(2)搜索为Arr[]中为 1 的位置,并找到与之相匹配的 0 ,cnt表示对应的匹配间1的个数。 3、注意事项:flag[i]标示Arr[i]是否已完成匹配;flag[]注意及时清空。 4、实现方法: #include<iostream>using namespace st...

weixin_33950035的博客 159

海康VisionMaster图形定位实战:十字形Mark点精准匹配技巧

本文深入解析了海康VisionMaster图形定位模块在工业自动化中实现十字形Mark点精准匹配的实战技巧。文章从ROI设置、核心参数调优(如定位方式、尺度模式、对比度阈值)到工业场景应用与避坑指南,系统性地分享了提升匹配成功率和稳定性的关键步骤,帮助工程师应对复杂现场环境,实现高效、可靠的视觉定位。

weixin_29285605的博客 271

【水文学法总结】河道内生态流量计算方法(含MATLAB实现代码)

简介水文学法实现河道内生态流量计算

WW、forever的博客 5028

Parencodings 模拟

Let S = s1 s2…s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2…pn where pi is the number of left parentheses before the ith right ...

博客标题不能为空我也没办法 331

【VS Code插件开发】通用功能(二)

本篇主要从command(命令)、menus(菜单)、快捷键三个方面讲解,都归于通用功能。

编码世界 1万+

Parencodings(poj模拟法)

Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses bef

jinzk123的博客 751

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Parencodings POJ 1068(模拟法)

问题:ParencodingsPOJ - 1068序列如4 5 6 6 6 6表示第i个")"前面有几个"(",求序列如1 1 1 4 5 6,即与第i个")"相匹配的"("是其前面的第几个"("分析:模拟法,模拟写括号,匹配括号的过程即可得到答案匹配过程:先读一个数num,然后把对应的"("都写上,相当于吧left[]填1填到num为止;然后开始从填的最后一位开始往前找1,找到1的同时记

勉強しているユキさんです 184

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

poj-1068 Parencodings 动态规划

题目链接 poj-1068 Parencodings 题目 Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27610   Accepted: 16233 Description Let S = s1 s2..

iwts 399

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

POJ1068 Parencodings

POJ1068 Parencodings题意描述输入输出Sample InputSample Output思路提交代码 题意 描述 用两种编码模式描述正确的括号字符串S: P = p1 p2…pn 其中 pi 是 S中第 i 个右括号之前的左括号数。 W = w1 w2…wn 其中wi是 S中第 i 个右括号和与其相匹配的左括号之间的右括号数(包含i,所以最少为 1)。本题要求要将输入的P序列转换为W序列。 输入 输入的第一行包含一个整数 t (1 <= t <= 10),即测试用例的数量,

wjqaea的博客 322

POJ 1068 Parencodings(模拟法)

Parencodings Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%lld & %llu Submit Status Practice POJ 1068 Appoint description:  System Crawler  (Nov 15, 2016 12:31:49 PM)

299

POJ模拟——Parencodings

Parencodings Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Description Let S = s1 s2...s2n be a

空白页 633

简单模拟|Parencodings

用p形式还原原数组 扫描原数组中的右括号,简单操作最后得出w形式 import java.util.Scanner; public class Parencoding { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { i...

My Blog 358

模拟法(poj 1068)Parencodings

Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith

ices_的博客 470

Parencodings(poj1068简单模拟)

/*http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#problem/B B - Parencodings Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit   Status   Practice

JHC23的专栏 757

[poj1068]Parencodings_模拟

Parencodings     题目大意:给你一个P序列,表示从左到右的右括号左边有多少左括号,求M序列。     注释:M序列定义为每一个右括号左边最近的没有被之前的右括号匹配的括号之间,有多少已经匹配的括号队对。$1\le number for P\le 20$。       想法:暴力模拟。我们定义dis[i]表示第i-1个右括号到第i个右括号之间有多少可以直接使用的左括号...

dianan0938的博客 146

POJ 1068 Parencodings

Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19185   Accepted: 11570 Description Let S = s1 s2...s2n be a well-formed string of parentheses.

叶孤心的专栏 484

POJ 1068 Parencodings(模拟)

Parencodings Time Limit:1000MS Memory Limit:10000K Total Submissions:13696 Accepted:8145 Description Let S = s1 s2...s2n be a well-formed strin...

weixin_30677617的博客 167

poj 1068 Parencodings

没什么算法,直接模拟。 /* * Author: stormdpzh * Time: 2012/5/11 20:07:00 * POJ: 1068 Parencodings */ #include #include #include #include #include #include #include #include #include #include #incl

stormdpzh的专栏 514
上一篇: n皇后问题
下一篇: Y2K Accounting Bug(简单枚举)
lrbj
博客等级 码龄14年 11粉丝 228原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值