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

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

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

用。

#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. 大约C++ const 全面总结

    C++中的const关键字的使用方法很灵活,而使用const将大大改善程序的健壮性,本人依据各方面查到的资料进行总结例如以下,期望对朋友们有所帮助. Const 是C++中经常使用的类型修饰符,常类型 ...

  2. ArcSDE SDK For Java二次开发介绍、演示样例

    在一个工作中,遇到了须要java后台来查询ArcGIS 中用到的Oracle数据库空间数据,因为对ArcGIS空间数据首次接触,仅仅知道Oracle能够使用ST_GEOMETRY字段存储,例如以下图 ...

  3. 发现SQL Server惊天大秘密!!

    原文:发现SQL Server惊天大秘密!! --set statistics xml onCREATE TABLE T_TEST(ID INT IDENTITY PRIMARY KEY,Create ...

  4. Android设计模式(十)--生成器模式

    回头看自己写的东西,大概Android当自己控制的定义,编写代码适用性比较高.但是,看看没有什么技术含量,因此,当在学习设计模式,想想有些东西是否可以改善,例如: 自己定义Dialog是Android ...

  5. BibTex (.bib) 文件的凝视

    1) 将某个參考文献所有去掉,能够去掉前面的『@』 样例 @article{##,    author = {###},    title = {###},    journal = {###},   ...

  6. Ozmosis实现BIOS直接启动Yosemite,基本完美

    我的主板是 技嘉 z97 d3h,共享一下我制作好的  Ozmosis

  7. 我学cocos2d-x (两) 采用Delegate(信托)

    Delegate(信托)什么 Delegate是ios开发中的一个概念,主要是为了让类A中的功能,放到类B中来实现,这样能够合理的把功能划分到不同的文件里进行实现,从而更好的实现模块的分离.如UIAp ...

  8. nginx 日志和监控

    原文地址:http://nginx.com/resources/admin-guide/logging-and-monitoring/ Logging and Monitoring 日志和监控 Thi ...

  9. docker 现实---联网多台物理主机,容器桥到物理网络(三)

    docker 默认桥接卡docker0 只有当这个单元中的所有容器桥接卡.例如,在主机虚拟网络适配器容器看通常称为veth***  和docker只要把这些卡桥接在一起,例如下面的附图: waterm ...

  10. 【iOS】Swift扩展extension和协议protocol

    加上几个关节前Playground摘要码进入github在,凝视写了非常多,主要是为了方便自己的未来可以Fanfankan. Swift语法的主要部分几乎相同的. 当然也有通用的.运算符重载.ARC. ...