poj 1068 Parencodings 模拟
进入每个' ) '多少前‘ ( ’,
我们力求在每‘ ) ’多少前‘ ) ’,
我的方法是最原始的图还原出来,去寻找‘)’。
用。
。
#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 模拟的更多相关文章
- POJ 1068 Parencodings 模拟 难度:0
		
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...
 - [ACM] POJ 1068 Parencodings(模拟)
		
Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19352 Accepted: 11675 De ...
 - poj 1068 Parencodings  模拟题
		
Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two diff ...
 - 模拟 POJ 1068 Parencodings
		
题目地址:http://poj.org/problem?id=1068 /* 题意:给出每个右括号前的左括号总数(P序列),输出每对括号里的(包括自身)右括号总数(W序列) 模拟题:无算法,s数组把左 ...
 - POJ 1068 Parencodings【水模拟--数括号】
		
链接: http://poj.org/problem?id=1068 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...
 - poj 1068 Parencodings(模拟)
		
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj ...
 - poj 1068 Parencodings(栈)
		
题目链接:http://poj.org/problem?id=1068 思路分析:对栈的模拟,将栈中元素视为广义表,如 (((()()()))),可以看做 LS =< a1, a2..., a1 ...
 - POJ 1068  Parencodings (类似括号的处理问题)
		
Pare ...
 - POJ 1068 Parencodings
		
Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24932 Accepted: 14695 De ...
 
随机推荐
- java javaEE javaWEB J2EE程序猿猿程序是脑损伤,终身工作程序猿
			
这几天我越来越郁闷.程序员现在很火----特javaEE员. 但我觉得火只是给人们的工作程序员. 原因 javaweb该项目是非常大的.没听过那个码农能单独接到什么项目.仅仅能被人剥削. 有人不信,我 ...
 - mysql语句中使用like后面的%(百分号)的问题
			
问题:mysql语句中使用like后面的%(百分号) 是不是越多运行效率越慢! 总用时:0.0489秒 0.0691 0.0485 0.0467 SELECT `goods_name`, `goods ...
 - IOS-QQ登陆之苹果程序流程
			
1.新建项目,通过main函数循环执行代码,直到应用被关闭. 2.点击项目,建立storyboard文件,并在info文件夹中指定第一个storyboard文件 3.建立Controller文件. 组 ...
 - Java学习路径:不走弯路,这是一条捷径
			
1.如何学习编程? JAVA是一种平台.也是一种程序设计语言,怎样学好程序设计不只适用于JAVA,对C++等其它程序设计语言也一样管用.有编程高手觉得,JAVA也好C也好没什么分别,拿来就用.为什么他 ...
 - 网络爬虫WebCrawler(1)-Http网页内容抓取
			
在windows在下面C++由Http协议抓取网页的内容: 首先介绍了两个重要的包(平时linux在开源包,在windows下一个被称为动态链接库dll):curl包和pthreads_dll,其中c ...
 - bcp sqlcmd bulkinsert在unicode问题,Unexpected EOF encountered in BCP data-file
			
senario 进入sqlcmd使用:out xxx产生的数据文件,因为sqlcmd export to file 默认情况下,中国的乱码.因此,使用-u(unicode)开关 @echo off & ...
 - 使用WireShark简单分析ICMP报文
			
ICMP协议介绍 1.ICMP是"Internet Control Message Protocol"(Internet控制消息协议)的缩写. 它是TCP/IP协议族的一个子协议. ...
 - Explicit keyword
			
说实话,从来没有感觉到这个keyword实用,直到今天. explicit的意思是明显的,和它相相应的一个词是implicit意思是隐藏的. 我參考了MSDN和<c++标准程序库>对这个k ...
 - JavaEE(19) - Web层和EJB的整合(Session Bean)
			
1. 通过依赖注入访问无状态Session Bean #1. EJB注入Servlet中 #2. EJB注入JSF中 2. 通过EJB引用访问有状态Session Bean 3. 在工具类中访问Ses ...
 - 什么是简单的分析SQL注入漏洞
			
如今非常多人在入侵的过程中基本都是通过SQL注入来完毕的,可是有多少人知道为什么会有这种注入漏洞呢?有的会随口说着对于字符的过滤不严造成的. 可是事实是这样吗?我们学这些.不仅要知其然.更要知其所以然 ...