进入每个' )  '多少前‘ (  ’,

我们力求在每‘ ) ’多少前‘ )  ’,

我的方法是最原始的图还原出来,去寻找‘)’。

用。

#include<stdio.h>
#include<string.h>
int y[505],t[505];
char s[505];
int main()
{
int a,b,i,j,u;
scanf("%d",&a);
while(a--)
{
memset(y,0,sizeof(y));
memset(t,0,sizeof(t));
memset(s,0,sizeof(s));
scanf("%d",&b);
for(i=0;i<b;i++)
{scanf("%d",&y[i]);
}
int sum=1;
int ans;
for(i=0,j=0;i<505;i++)
{
if(sum<=y[j])
{
s[i]='(';
sum++;
}
else
{
s[i]=')';
j++;
}
if(j>=b)
break;
}
u=strlen(s);
for(i=0;i<u;i++)
{
if(s[i]=='(')
continue;
else
{
ans=1;
t[i]=1;
for(j=i-1;j>=0;j--)
{
if(s[j]==')')
ans++;
if(t[j]==0)
{
if(s[j]=='(')
{t[j]=1;break;}
}
}
printf("%d ",ans);
}
}
printf("\n");
}
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

poj 1068 Parencodings 模拟的更多相关文章

  1. POJ 1068 Parencodings 模拟 难度:0

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

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

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

  3. poj 1068 Parencodings 模拟题

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

  4. 模拟 POJ 1068 Parencodings

    题目地址:http://poj.org/problem?id=1068 /* 题意:给出每个右括号前的左括号总数(P序列),输出每对括号里的(包括自身)右括号总数(W序列) 模拟题:无算法,s数组把左 ...

  5. POJ 1068 Parencodings【水模拟--数括号】

    链接: http://poj.org/problem?id=1068 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...

  6. poj 1068 Parencodings(模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj ...

  7. poj 1068 Parencodings(栈)

    题目链接:http://poj.org/problem?id=1068 思路分析:对栈的模拟,将栈中元素视为广义表,如 (((()()()))),可以看做 LS =< a1, a2..., a1 ...

  8. POJ 1068 Parencodings (类似括号的处理问题)

                                                                                                    Pare ...

  9. POJ 1068 Parencodings

    Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24932   Accepted: 14695 De ...

随机推荐

  1. iphone内容开发技术学习

    一.iOS基础 1 开发环境搭建以及IOS组件.框架的概要介绍. 2 mac操作系统与iOS操作系统 3 xcode IDE开发环境的初始 二.C语言基础 1数据类型.表达式与控制流程语句 2数组.函 ...

  2. 【Bible for kids】 儿童圣经 App

    [Bible for kids] 儿童圣经App 除了<The Bible>这个由YouVersion团队开发的全球下载量和安装数目第一的圣经类.安装量已逾1亿8千万的App之外,YouV ...

  3. NLP | 自然语言处理 - 解析(Parsing, and Context-Free Grammars)

    什么是解析? 在自然语言的学习过程,个人一定都学过语法,比如句子能够用主语.谓语.宾语来表示.在自然语言的处理过程中.有很多应用场景都须要考虑句子的语法,因此研究语法解析变得很重要. 语法解析有两个基 ...

  4. Integer比较

    /** * @time 2014-06-25 * @author Cao HaiCheng * */ public class demo { public static void main(Strin ...

  5. poj 2417 Discrete Logging(A^x=B(mod c),普通baby_step)

    http://poj.org/problem?id=2417 A^x = B(mod C),已知A,B.C.求x. 这里C是素数,能够用普通的baby_step. 在寻找最小的x的过程中,将x设为i* ...

  6. 设置状态栏样式Demo

    达到的效果: 色有黑色变为了白色 //设置状态条的样式 - (UIStatusBarStyle)preferredStatusBarStyle { returnUIStatusBarStyleLigh ...

  7. 协议系列UDP协议

    所述上部TCP虽然该协议提供了一个可靠的传输,但也有一个缺点.发送速度慢.是否有协议它可以以高速传送?这部分是将要讨论UDP协议,它提供了更加快了传输速度.而且在可靠性为代价,这是一个无连接的传输协议 ...

  8. Linux解析内核源代码——传输控制块诞生

    原创文章是freas_1990,转载请注明出处:http://blog.csdn.net/freas_1990/article/details/23795587 在Linux 2.6一旦(不包含2.6 ...

  9. Flex TextInput 动态推断输入内容

    Flex TextInput 动态推断输入内容 <? xml version="1.0" encoding="utf-8"?> <s:Appl ...

  10. wikioi 1034 家 实时动态的网络流量(费用流)

    因为随着时间的推移.网络侧变得,因此,常见的网络流量也解决不了这个问题,.如果T毕竟运输时间. 为此.我们可以基于时间分割点,所有的点将被分割为T点. 对于每一个点,下一次甚至一个容量为本人INF边缘 ...