:Parencodings

工业组态软件Intouch(单机版)入门{第一篇} 通俗来讲Intouch就是一个能将PLC里的信号显示在画面上的软件。 阅读详情

 

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 = 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.
输入
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.
输出
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.
样例输入
2
6
4 5 6 6 6 6
9 
4 6 6 6 6 8 9 9 9
样例输出
1 1 1 4 5 6
1 1 2 4 5 1 1 3 9

我是按模拟的方法做的,代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a[40], b[40];
int main()
{
    int t, x, m, n, i;
    scanf("%d", &t);
    m = 0;
    while(t--){
        memset(a, -1, sizeof(a)); //赋值为-1
        scanf("%d", &n);
        for(i=0; i<n; i++){
            scanf("%d", &x);
            if(a[x]==-1){
                b[i] = 1;
                a[x] = 0;
            }
            else
            {
                m = 1;
                while(a[x]!=-1){
                    x--;
                    m++;
                }
                b[i] = m;
                a[x] = 0;
            }
        }
        for(i=0; i<n; i++){
            printf("%d ", b[i]);
        }
        printf("\n");
    }
    return 0;
}


 

 

用deepseek对GPU服务器进行压力测试 利用 DeepSeek 模型对 GPU 服务器进行压力测试,核心思路是通过,验证 GPU 服务器在计算、显存、网络等维度的承载能力,同时观察稳定性与性能瓶颈。 阅读详情

相关推荐

Flowable多数据源实战:从配置到指定Schema的避坑指南

本文详细介绍了Flowable多数据源配置的实战指南,包括基础配置、数据源Bean创建、指定Schema的进阶配置以及常见问题排查。通过具体代码示例和避坑建议,帮助开发者高效实现多租户系统中的工作流引擎集成,特别强调了schema设置和事务管理的注意事项。

weixin_30824599的博客 489

PAT.Advanced.P1068

------>   原题链接    题意大概是有1w个硬币,店家只要精确数额(不多收也不找零)问能否凑出给出的数额。 做法就是暴力循环 + 剪枝优化 不剪枝的话有一个点是过不去的。 1、剔除所有大于给定数量的硬币, 2、对于重复的硬币,如果第一个不行,那么排除掉后面所有的重复硬币的可能性。(见注释的核心剪枝行) #include #include #include #inclu

A.Z.L的博客 454

阿里云Ubuntu部署Steam饥荒联机版服务器:从零到多人联机的完整指南

本文详细介绍了在阿里云Ubuntu系统上部署Steam饥荒联机版服务器的完整流程,包括环境准备、SteamCMD安装、服务端配置、Mod管理及后台运行技巧。通过2核4GB的ECS实例配置和端口设置,实现5人流畅联机体验,适合游戏爱好者快速搭建专属服务器。

weixin_29229261的博客 1037

1068:Parencodings

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

weixin_49403900的博客 215

LPC546xx USB接口VBUS阈值设计:从原理到实践,解决冷启动与可靠性问题

在嵌入式USB接口设计中,VBUS信号不仅是电源线,更是设备连接检测与电源管理的核心。其电压阈值直接决定了USB物理层(PHY)能否正确识别主机并建立有效会话。理解VBUS的会话有效电压(Votg_sess_valid)与PHY有效电压(VBUS_valid)等关键参数,是确保接口稳定性的基础。这些参数影响着设备枚举的成功率、通信稳定性以及长期可靠性。在工程实践中,尤其是对于集成PHY的微控制器如NPC LPC546xx系列,VBUS的连接方案(直接连接或通过稳压器)需要根据设备供电模式(自供电/总线供电)

weixin_30915275的博客 405

雷达系统仿真——非相参累积和相参累积检测

非相参累积和相参累积检测 在雷达回波检测中,在特殊情况下,才会根据单个脉冲来进行检测判决。通常,雷达会从每个目标接收几个到几百个成串脉冲,在做出判决之前,要先对脉冲串进行处理。对脉冲串进行处理的方法有5种: 相参累积(Coherent Integration); 非相参累积(Nocoherent Integration); 二进制累积; 累计检测; 反馈累积器。 1 非相参累积 也叫“检波后累积”,或者“视频累积”(Video Integration),比检波前累积更容易完成,因为不需要保存回波的相位。

little_soldier的专栏 1万+

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

3.1 计算机视觉的发展和卷积神经网络概要(百度架构师手把手带你零基础实践深度学习原版笔记系列)

3.1 计算机视觉的发展和卷积神经网络(百度架构师手把手带你零基础实践深度学习原版笔记系列) 概要 计算机视觉作为一门让机器学会如何去“看”的科学学科,具体的说,就是让机器去识别摄像机拍摄的图片或视频中的物体,检测出物体所在的位置,并对目标物体进行跟踪,从而理解并描述出图片或视频里的场景和故事,以此来模拟人脑视觉系统。因此,计算机视觉也通常被叫做机器视觉,其目的是建立能够从图像或者视频中“感知”信息的人工系统。 计算机视觉技术经过几十年的发展,已经在交通(车牌识别、道路违章抓拍)、安防(人脸闸机.

aiAI 694

Parencodings(简单模拟法)

链接: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

JHC23的专栏 1821

WorkBuddy CAD 审图救命课:约束、单位、尺寸链一次查清,打样前拦住返工

最危险的 CAD 文件不是打不开,而是看起来完整却混用了毫米与英寸、草图欠约束、关键尺寸没有来源。审图任务必须先列规则,再输出问题位置。 本课不会用“AI 一键完成”制造错觉,而是把 WorkBuddy、FreeCAD 0.21.2、OpenCascade 7.7 与人工审阅组成一条可复现链路。你会从“一份模拟 STEP 文件、参数表、装配基准与审图标准”出发,得到“单位报告、约束清单、尺寸链风险表与人工复核标记”,并学会用真实命令、错误信号和停止条件判断成果能不能进入下一阶段。

yueyeguzhuo的专栏 289

【ROS】ROS2导航Nav2:简介、安装、测试效果、错误处理

在ROS2中自动导航使用Nav2来实现。Nav2 使用几个独立的模块化服务,通过 ROS 2接口(例如动作服务器或服务)与行为树 (BT) 通信。Nav2 输入包括:TF转换、一个地图源、一个行为树 (BT) XML 文件和相关的传感器数据源;Nav2 输出速度命令;Nav2 支持多种机器人,比如:四足机器人、履带机器人、轮式机器人等。

郭老二 5105

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

汽车IVI中控开发入门及进阶(47):CarPlay开发

车载信息娱乐(IVI)系统已经从仅仅播放音乐的设备发展成为现代车辆的核心部件。除了播放音乐,IVI系统还为驾驶员提供导航、通信、空调、电源配置、油耗性能、剩余行驶里程、节能建议和许多其他功能。​驾驶座逐渐变成了你家和工作场所之外的额外生活空间。2014年,苹果推出了Apple CarPlay,这是一款汽车界面,允许驾驶员使用iPhone应用程序和其他IVI功能,如苹果地图、Siri、苹果音乐、iMessage,并拨打电话。

码农17年的博客 1132

Poj 1068:Parencodings

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

Valieli的博客 572

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

1044: Parencodings

<br /> 1044: ParencodingsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K613302Standard<br />Let S = s1 s2 … s2n be a well-formed string of parentheses. S can be encoded in two different ways:By an integer sequence P = p1 p2 … pn where pi is the n

kongming_acm的专栏 399

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

ACM 算法题:Parencodings

对于正常的括号对序列,也就是左括号与右括号的数目是相等的,并且成对。例如(((()()()))),总共有n个括号。 通过两种形式对括号对编码: P序列: P = p1 p2 … pn Pi是第i个右括号之前左括号的数目。 W序列: W = w1 w2 … wn Wi是第i个右括号与之匹配及其包含的左括号的数目。 要求:写一个算法,将括号对的P序列转换成W序列。

vshadow的专栏 924

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

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

POJ 刷题系列:1068. Parencodings

POJ 刷题系列:1068. Parencodings传送门:1068. Parencodings题意: 给出一组P-Sequence,每个数代表当前右括号之前的所有左括号数,求W-Sequence,表示当前右括号与它对应的左括号之间的左括号数。还是看例子吧: 思路: 抓住两点,对应于P-Sequence,对于每个右括号i,插入的左括号数为p[i] - p[i - 1]。对于W-Seq

Demon-初来驾到 504

POJ1068《Parencodings》方法:模拟

题目大意:将一种括号表现形式转变为另一种,通过变为中间字符串000010101111的形式转化,easy。 #include #include #include using namespace std; int main() { //freopen("temp.txt", "r", stdin); int t, n; int p[21] = {0}; //P串,p[0]=0很重

相门码农的专栏 457

ZOJ--1016:Parencodings

Parencodings Time Limit: 2 Seconds      Memory Limit: 65536 KB Let S = s1 s2 ... s2n be a well-formed string of parentheses. S can be encoded in two different ways: By an integer sequenc

yf224的博客 451

POJ 1068:Parencodings

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

532

POJ:1086-Parencodings

ParencodingsTime Limit: 1000MS Memory Limit: 10000KDescriptionLet 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

二营长的意大利炮友 291

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 right pare

并非所有流浪者都迷失了自我 489

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 分类: POJ 20...

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

weixin_30275415的博客 69

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

POJ 1068 Parencodings 模拟 难度:0

http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; int ind[45]; bool used[45]; int r[21]; int l[21]; int len,n,llen; int w[21]; int main(){...

weixin_30814329的博客 98
下一篇: 最短回文串
GOFORACM
博客等级 码龄15年 0粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值