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: ...
随机推荐
- CodeBlocks使用技巧
快键键 注释:选中后Shfit + C 取消注释:选中后Shfit + X 查找替换:Ctrl + R Build(Ctrl + F9) Run (Ctrl + F10) Build + Run (F ...
- js call与apply的区别-Tom
.apply和.call方法是在函数原型中定义的两个方法(因此所有的函数都可以访问它)允许去手动设置函数调用的this值,他们用接受 的第一个参数作为this值,this 在调用的作用域中使用.这两个 ...
- poj2208Pyramids(四面体面积--公式)
链接 一公式题.. 证明讲解参照http://www.cnblogs.com/dgsrz/articles/2590309.html 注意对棱 顺序 #include <iostream> ...
- hdu4588Count The Carries
链接 去年南京邀请赛的水题,当时找规律过的,看它长得很像数位dp,试了试用数位dp能不能过,d出每位上有多少个1,然后TLE了..然后用规律优化了前4位,勉强过了. 附数位dp代码及找规律代码. #i ...
- python的最最最最最基本语法(2)
函数的定义: 使用def语句,依次写出函数名.括号.括号中的参数和冒号:,然后,在缩进块中编写函数体,函数的返回值用return语句返回. 当用return 返回多个值时,返回的其实是一个tuple, ...
- asc.desc
DESC 是descend 降序意思 asc 是ascend 升序的意思
- 将一堆石子分成多堆——Multi-SG 游戏
这类博弈只需要记住一点,一个由多个游戏组成的游戏sg值为这多个游戏的sg值异或和. 也就是所有对一整个nim游戏它的sg值即为每一小堆的sg的异或和. hdu 5795 这题就是可以选择把一堆石子分成 ...
- xmpp怎么让群主踢人?
不知道其他语言版的xmpp,framework是怎样的,就OC版提供的xmpp框架来说,它只提供了邀请其他用户进群的API: - (void)inviteUser:(XMPPJID *)jid wit ...
- http协议简述
HTTP协议 客户端连上web 服务器后,若想获得 web 服务器中的某个 web 资源,需遵守一定的通讯格式, HTTP 协议用于定义客户端与 web 服务器通迅的格式. WEB浏览器与 WEB 服 ...
- 利用php CI force_download($filename, $data) 下载.csv 文件解决文件名乱码,文件内容乱码
利用php CI force_download($filename, $data) 下载.csv 文件解决文件名乱码,文件内容乱码 2014-07-31 12:53 1047人阅读 评论(0) 收藏 ...