POJ 1068 Parencodings 模拟 难度:0
http://poj.org/problem?id=1068
#include<cstdio>
#include <cstring>
using namespace std;
int ind[45];
bool used[45];
int r[21];
int l[21];
int len,n,llen;
int w[21];
int main(){
int t;
scanf("%d",&t);
while(t--){
memset(used,0,sizeof(used));
len=0,llen=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",r+i);
for(int j=0;j<r[i]-(i>0?r[i-1]:0);j++){
ind[len++]=llen;
l[llen++]=i;
}
ind[len++]=i;
}
for(int i=0;i<n;i++){
int tind=r[i]+i;
used[tind]=true;
for(int j=tind-1;j>=0;j--){
if(!used[j]){
w[i]=i-l[ind[j]]+1;
used[j]=true;
break;
}
}
}
for(int i=0;i<n;i++)printf("%d%c",w[i],i==n-1?'\n':' ');
}
return 0;
}
POJ 1068 Parencodings 模拟 难度:0的更多相关文章
- [ACM] POJ 1068 Parencodings(模拟)
Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19352 Accepted: 11675 De ...
- poj 1068 Parencodings 模拟
进入每个' ) '多少前' ( ', 我们力求在每' ) '多少前' ) ', 我的方法是最原始的图还原出来,去寻找')'. 用. . #include<stdio.h> #incl ...
- 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 2632 Crashing Robots 模拟 难度:0
http://poj.org/problem?id=2632 #include<cstdio> #include <cstring> #include <algorith ...
- POJ 1573 Robot Motion 模拟 难度:0
#define ONLINE_JUDGE #include<cstdio> #include <cstring> #include <algorithm> usin ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
随机推荐
- windos命令行下的程序编写
1.命令行下写程序. 写程序一定要用IDE?不,我还可以用记事本呢.呵呵,写程序一定要用记事本?? ———————————————— 命令行下输入copy con test.txt后回车可在相应目录下 ...
- org.apache.jasper.JasperException: Expecting "jsp:param" standard action with "name" and "value" attributes
jasper 英 ['dʒæspə] 美 ['dʒæspɚ] 跟读 口语练习 n. 碧玉:墨绿色 n. (Jasper)人名:(德)雅斯佩尔:(西)哈斯佩尔 JasperException 异 ...
- 初试Celery
从@到celery 一.文档: 官网:http://www.celeryproject.org/ Celery3.1 ------------2016-7-19 18:26:55-- source:[ ...
- Http状态总结
常见的http状态总结: 如果向您的服务器发出了某项请求要求显示您网站上的某个网页,那么,您的服务器会返回 HTTP 状态代码以响应该请求.一些常见的状态代码为: 200 - 服务器成功返回网页 40 ...
- poj3334Connected Gheeves(二分)
链接 二分高度,算面积的地方有点麻烦,没有用求交点的模板,直接自己按三角形相似手算了一下,写的有点麻烦. 上下界直接取水可放的最高点以及最低点. 自己的长得很挫的代码 #include <ios ...
- iframe页面调用父窗口JS函数
A页面iframe 页面B, 此时 如果要在B页面调用父页面A的函数 B页面写法 parent.functionName(); 错误1: 解决办法 var js_domain_async = 'bai ...
- js倒计时 网上流传最多的
<!DOCTYPE html><html><head><script src="http://libs.baidu.com/jquery/1.10. ...
- 2016最全的web前端面试题及答案整理
面试web前端开发,不管是笔试还是面试,都会涉及到各种专业技术问题,今天小编整理了一些常见的web前端面试题及答案,希望对大家有所帮助. 1.常用那几种浏览器测试?有哪些内核(Layout Engin ...
- 安卓虚拟机启动失败intel haxm未安装
1:环境是android studio 在AVD中启动显示,提示当前电脑为安装HAXM emulator: ERROR: x86 emulation currently requires hardwa ...
- windows redis:Uncaught exception 'RedisException' with message 'Redis server went away'
window-exe-redis-2.8.12服务,当你复制好php_igbinary.dll,php_redis.dll时候,你运行redis报错:Fatal error: Uncaught exc ...