题目链接

分析:

水题。

#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(模拟)的更多相关文章

  1. [POJ1068]Parencodings

    [POJ1068]Parencodings 试题描述 Let S = s1 s2...s2n be a well-formed string of parentheses. S can be enco ...

  2. [ACM_模拟] POJ1068 Parencodings (两种括号编码转化 规律 模拟)

    Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two diff ...

  3. POJ1068——Parencodings

    Parencodings Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encode ...

  4. [poj1068]Parencodings_模拟

    Parencodings 题目大意:给你一个P序列,表示从左到右的右括号左边有多少左括号,求M序列. 注释:M序列定义为每一个右括号左边最近的没有被之前的右括号匹配的括号之间,有多少已经匹配的括号队对 ...

  5. PO1068 Parencodings 模拟题

    Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28860   Accepted: 16997 De ...

  6. Hdu1361&&Poj1068 Parencodings 2017-01-18 17:17 45人阅读 评论(0) 收藏

    Parencodings Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total ...

  7. [ACM] POJ 1068 Parencodings(模拟)

    Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19352   Accepted: 11675 De ...

  8. POJ 1068 Parencodings 模拟 难度:0

    http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...

  9. poj 1068 Parencodings 模拟

    进入每个' )  '多少前' (  ', 我们力求在每' ) '多少前' )  ', 我的方法是最原始的图还原出来,去寻找')'. 用. . #include<stdio.h> #incl ...

随机推荐

  1. PNG文件格式具体解释

      PNG文件结构分析(上:了解PNG文件存储格式) 前言 我们都知道,在进行J2ME的手机应用程序开发的时候,在图片的使用上,我们能够使用PNG格式的图片(甚至于在有的手机上,我们仅仅能够使用PNG ...

  2. redis+keeplived分布式缓存

    redis(三)redis+Keepalived主从热备秒级切换 博客分类: 分布式缓存Redis redis高可用Keepalived  一 简介 安装使用centos 5.10 Master 19 ...

  3. JAVA中的继承和覆盖

    java里面的继承是子类继承父类的一些方法和属性(除private属性和方法之外):对于父类的私有属性和方法子类是没有继承的.可是要想子类也能訪问到父类的私有属性,必须给私有属性以外界訪问的方法接口. ...

  4. Git 版本控制工具使用介绍------Windows系统下使用

    Git 是用于 Linux内核开发的版本控制工具.与常用的版本控制工具 CVS, Subversion 等不同,它采用了分布式版本库的方式,不必服务器端软件支持(wingeddevil注:这得分是用什 ...

  5. centos7.2下安装mysql5.7,使用rpm包安装

    0.环境 本文操作系统: CentOS 7.2.1511 x86_64 MySQL 版本: 5.7.16 1.卸载系统自带的 mariadb-lib[root@centos-linux ~]# rpm ...

  6. codevs 1689 搭建高塔

    /*机智sort二维转一维*/ #include<iostream> #include<cstdio> #include<cstring> #include< ...

  7. codevs1051单词接龙(栈)

    /* 看到n的范围就觉得这个不可能是DP啥的 因为这个接龙的规则十分的简单 只要前缀相同即可 所以先按字典序排一遍 这样保证符合规则的一定挨着 然后弄一个stack 每次拿栈顶元素看看待入栈的元素是否 ...

  8. C#解leetcode 189. Rotate Array

    Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array  ...

  9. oracle 关于动态执行语句 execute immediate 的用法

    当在开发的应用场景中 数据库处理复杂业务逻辑里用到 SQL 语句拼接    可以用  execute immediate   来执行语 举个例子 insert into tb_temp_public( ...

  10. node.js常用的几个模块总结

    /** 一 util *      是 node 里面一个工具模块 ,node 里面几乎所有的模块 都会用到 在这个模块 *  功能: *      1 实现继承 这是主要功能 *      2 实现 ...