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 ...
随机推荐
- 【C语言探索之旅】 开宗明义及第一课:什么是编程?
内容简介 1.课程大纲 2.第一部分第一课:什么是编程? 3.第一部分第二课预告:工欲善其事,必先利其器 课程大纲 不知道为什么,一直对C语言有一种很深厚的“情怀”(类似老罗对锤子手机的那种),说 ...
- Socket编程实践(4) --更复杂的过程server
1.Socket地址复用 int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); in ...
- codeigniter 该脚本在运行300s超时退
直接看代码, file:system/core/CodeIgniter.php /* 102 * -------------------------------------------------- ...
- Android笔记 之 旋转木马的音乐效果
一.前言-- 大家一定在百度音乐上在线听过歌,有没有注意到那个旋转唱片-- 就上面那个,当音乐在播放的时候,那个光碟轮子在转,就想旋转木马一般.感觉好好玩啊. 碰巧想起前阵子做音乐播放器,哎,那这个也 ...
- OpenGL路(四)自制的图形功能(立方体、汽缸、圆锥)
#include <gl/glut.h> #include <gl/GLU.h> #include <gl/GL.h> #pragma comment(lib, & ...
- 有关windows在调试ODOO8.0有些问题
继Ubuntu建筑物8.0调试环境后,,尝试windows设置开发环境. 最后的调试和开发,或将返回Linux环境,由于前一段时间手贱,改变分区表,该grub搞哈.哎!后来重建mbr,手动检索分区表( ...
- Google大数据三篇著名论文----中文版
Google File System中文版 Google Bigtable中文版 Google MapReduce中文版
- YARN简短的建筑
从Hadoop的0.23版本号,MapReduce进行了全面的彻底的变革.也就是我们今天看到的MapReduce 2.0或者我们也能够叫它YARN. 老版本号的JobTracker有两个基本的功能:资 ...
- crontab演出newLISP脚本设置环境变量
今天遇到一个问题.执行在终端newLISP文字,一切正常,搬去crontab在将无法正常工作.即使crontab -e命令是在同一个用户执行.还是有问题. 因为newLISP脚本使用hive和hado ...
- java jdk缓存-128~127的Long与Integer
先推断下以下代码的输出结果 Qa:---------------------------------------------- Long a = Long.valueOf(127) ...