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: ...
随机推荐
- FlashPlayer for Android
1. Manually install on Android devices 教程地址:“https://helpx.adobe.com/flash-player/kb/installing-flas ...
- 学习日记day 10 : JavaScript秋风扫落叶第一期
1:实参形参概念清晰化 注意调用,声明和定义的区别. 调用发过去的都是实参,声明和定义中使用的都是形参. 例子: funcOperate (int a); //这是函数声明:参数都是形参: int ...
- 关于协程的学习 & 线程栈默认10M
先看的这篇文章:http://blog.csdn.net/qq910894904/article/details/41699541 以nginx为代表的事件驱动的异步server正在横扫天下,那么事件 ...
- golang type 和断言 interface{}转换
摘要 类型转换在程序设计中都是不可避免的问题.当然有一些语言将这个过程给模糊了,大多数时候开发者并不需要去关 注这方面的问题.但是golang中的类型匹配是很严格的,不同的类型之间通常需要手动转换,编 ...
- laravel 开启sql查询日志
\DB::enableQueryLog(); dd(\DB::getQueryLog());
- OpenGL的gluLookAt和glOrtho的关系
OpenGL的gluLookAt和glOrtho的关系 一直不明白gluLookAt()和glOrtho()两者之间的关系:gluLookAt()是观察变换,glOrtho()是正交投影.glLook ...
- PHP获取某年第几周的开始日期和结束日期
http://blog.csdn.net/qq_27080247/article/details/50835956 /** * 获取某年第几周的开始日期和结束日期 * @param int $year ...
- mysql下sql语句 update 字段=字段+字符串
mysql下sql语句 update 字段=字段+字符串 mysql下sql语句令某字段值等于原值加上一个字符串 update 表明 SET 字段= 'feifei' || 字段; (postgr ...
- mysql+tomcat+spring 配置心得(从0开始搭环境)
前几天公司竞一个标要做个POC,前端AugularJs做mobile界面,后端Spring MVC做Restful API供前端调用. 时间紧急,大家都忙,so我这个不写代码的闲人花一上午配了一套Sp ...
- DSP EPWM学习笔记1 - EPWM定时中断
DSP EPWM学习笔记1 - EPWM定时中断 彭会锋 EPWM模块组成 EPWM有7个子模块组成:时间基准 TB.比较功能 CC.动作限定 AQ.死区产生 DB.斩波控制 PC.故障捕获 TZ.事 ...