POJ1068 Parencodings(模拟)
题目链接。
分析:
水题。
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int maxn = ; int P[maxn], W[maxn];
char s[maxn]; int main(){
int T, n, m; scanf("%d", &T); while(T--) {
scanf("%d", &n);
P[] = ;
for(int i=; i<=n; i++) scanf("%d", &P[i]); //通过P推s
int cn = ;
for(int i=; i<=n; i++) {
for(int j=; j<P[i]-P[i-]; j++) {
s[cn++] = '(';
}
s[cn++] = ')';
}
s[cn++] = '\0'; //通过s推W
int rp_cnt = , lp_cnt, t, ls_cnt; for(int i=; i<cn; i++) {
if(s[i] == ')') {
rp_cnt++;
lp_cnt = t = ls_cnt = ;
for(int j=i; j>=; j--) {
if(s[j] == ')') { t++; ls_cnt++; }
else if(s[j] == '(') lp_cnt++;
if(lp_cnt == ls_cnt) break;
}
W[rp_cnt] = t;
}
} for(int i=; i<=n; i++) {
if(i != n) printf("%d ", W[i]);
else printf("%d\n", W[i]);
}
} return ;
}
POJ1068 Parencodings(模拟)的更多相关文章
- [POJ1068]Parencodings
[POJ1068]Parencodings 试题描述 Let S = s1 s2...s2n be a well-formed string of parentheses. S can be enco ...
- [ACM_模拟] POJ1068 Parencodings (两种括号编码转化 规律 模拟)
Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two diff ...
- POJ1068——Parencodings
Parencodings Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encode ...
- [poj1068]Parencodings_模拟
Parencodings 题目大意:给你一个P序列,表示从左到右的右括号左边有多少左括号,求M序列. 注释:M序列定义为每一个右括号左边最近的没有被之前的右括号匹配的括号之间,有多少已经匹配的括号队对 ...
- PO1068 Parencodings 模拟题
Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28860 Accepted: 16997 De ...
- Hdu1361&&Poj1068 Parencodings 2017-01-18 17:17 45人阅读 评论(0) 收藏
Parencodings Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- [ACM] POJ 1068 Parencodings(模拟)
Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19352 Accepted: 11675 De ...
- POJ 1068 Parencodings 模拟 难度:0
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...
- poj 1068 Parencodings 模拟
进入每个' ) '多少前' ( ', 我们力求在每' ) '多少前' ) ', 我的方法是最原始的图还原出来,去寻找')'. 用. . #include<stdio.h> #incl ...
随机推荐
- 山东省赛J题:Contest Print Server
Description In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source c ...
- J2EE之WebLogic Server
WebLogic是用于开发.集成.部署和管理大型分布式Web应用. 网络应用和数据库应 用的Java应用server. 将Java的动态功能和Java Enterprise标准的安全性引入大型网络应用 ...
- Linux TCP队列相关参数的总结
作者:阿里技术保障锋寒 原文:https://yq.aliyun.com/articles/4252 摘要: 本文尝试总结TCP队列缓冲相关的内核参数,从协议栈的角度梳理它们,希望可以更容易的理解和记 ...
- Visual C++内存泄露检测—VLD工具使用说明
一. VLD工具概述 Visual Leak Detector(VLD)是一款用于Visual C++的免费的内存泄露检测工具.他的特点有:可以得到内存泄漏点的调用堆栈,如果可以的话,还 ...
- HDFS Architecture--官方文档
HDFS Architecture Introduction The Hadoop Distributed File System (HDFS) is a distributed file syste ...
- 详解Android Handler的使用-别说你不懂handler(转)
我们进行Android开发时,Handler可以说是使用非常频繁的一个概念,它的用处不言而喻.本文就详细介绍Handler的基本概念和用法. Handler的基本概念 Handler主 ...
- My.Ioc 的性能
IoC/DI 这个概念,最初是由 Martin Fowler 提出来的.之后,很快在 Java 社区大行其道.在 .net 社区,IoC 的流行要比 Java 晚一些.尽管如此,现在开源社区中也已经出 ...
- ueditor asp.net版本更改图片保存路径
目的:把本地上传的图片放置到跟目录下的Images/Upload文件夹下. 修改步骤: 1.ueditor.config.js文件中的, imagePath: URL + "net/&quo ...
- CSS 布局Float 【1】
1.HTML元素分类 HTML元素大题可分为内联(inline)元素和块(block)元素. 1.1 内联元素(inline) ①元素显示方式:"文本方式",1个挨着1个,不独自占 ...
- wpf 控件复制 克隆
方法1: string xaml = System.Windows.Markup.XamlWriter.Save(rtb1); RichTextBox rtb2 =System.Windows.Mar ...