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: ...
随机推荐
- ubuntu安装jdk-6u45-linux-x64.bin___ZC_20160423
for : Android4.4源码编译 环境 : ubuntu12.04_desktop_amd64 1. 1.1.jdk-6u45-linux-x64.bin 放置于 /home 1.2.命令&q ...
- Python学习(5)条件语句
目录 Python 条件语句 Python 简单的语句组 Python 条件语句 Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. 可以通过下图来简单了 ...
- mysql 检查字符串是否包含子串
1.使用substring_index(src,target,index) 从src的开头查找第index个target.返回的substring为从src的开头到第num个target这段字符串.比 ...
- JS---------->数组练习!
var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0]; 要求将数组中的0项去掉,将不为0的值存入一个新的数组,生成新的数组 <!doctype htm ...
- Make 教程
Make 命令教程 原文作者: 阮一峰 原文链接:http://www.ruanyifeng.com/blog/2015/02/make.html (在原文基础上稍作修改) 代码变成可执行文件,叫做编 ...
- UIImageView 的contentMode属性
UIViewContentModeScaleToFill UIViewContentModeScaleAspectFit UIViewContentModeScaleAspectFill UIView ...
- jQuery动态加载脚本 $.getScript();
jQuery.getScript("/path/to/myscript.js", function(data, status, jqxhr) { /* ...
- laravel各种路径的获取方法
若Route中有Route::get('home/test', 'HomeController@index')->name('test'); ①视图中的href跳转 一.<a href=& ...
- Html_在线客服静态网页
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- base64 数据处理
base64 数据处理 1. base64 字母表 2. 原理 处理原理 http://baike.baidu.com/view/469071.htm 3. iOS上的应用 iOS7 之前使用http ...