poj 1068 Parencodings (模拟)
2012-03-06 21:53
399 查看
题意:
先输入右括号前左括号的数量
输出每个括号所含括号的数量(从左至右)
思路:
由于以前模拟题留下太大的阴影,比较凌乱:没想到今天 模拟1Y
虽然题简单点,就是用-1 1 模拟 括号 ,向前搜索即可
先输入右括号前左括号的数量
输出每个括号所含括号的数量(从左至右)
思路:
由于以前模拟题留下太大的阴影,比较凌乱:没想到今天 模拟1Y
虽然题简单点,就是用-1 1 模拟 括号 ,向前搜索即可
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int flag[50],top=0; int first,m; scanf("%d",&m);first=m; while(m--) flag[top++]=-1; flag[top++]=1; for(int i=1;i<n;i++) { scanf("%d",&m); int num=m-first; first=m; while(num--) { flag[top++]=-1; } flag[top++]=1; } for(int i=0;i<top;i++) { int sum=0,num=0; if(flag[i]==1) { sum=0,num=0; int di=i; while(di>=0) { if(flag[di]==-1) sum++; num+=flag[di--]; if(num==0) break; } printf("%d ",sum); } } printf("\n"); } }
相关文章推荐
- POJ 1068 Parencodings 模拟 栈操作
- [ACM] POJ 1068 Parencodings(模拟)
- poj 1068 Parencodings(模拟)
- POJ 1068 Parencodings(模拟)
- poj 1068 Parencodings(模拟)
- poj 1068 Parencodings——模拟
- [poj1068]Parencodings_模拟
- poj 1068 Parencodings 模拟
- poj 1068 Parencodings(模拟)
- Parencodings(POJ1068 模拟)
- poj1068 Parencodings 模拟 栈
- [ACM_模拟] POJ1068 Parencodings (两种括号编码转化 规律 模拟)
- POJ 1068 Parencodings (模拟),暑假第一题~
- POJ 1068 Parencodings(模拟)
- POJ 1068 Parencodings 模拟-括号匹配
- POJ 1068 Parencodings (模拟),暑假第一题~
- POJ 1068--Parencodings--括号逆匹配(模拟)
- poj-1068 Parencodings--模拟法
- poj 1068 Parencodings(模拟)
- POJ 1068 Parencodings【水模拟--数括号】