【瞎搞】 HDU 1361 Parencodings 括号
来源:互联网 发布:微信抢红包排雷软件 编辑:程序博客网 时间:2024/06/18 01:03
给出一串括号 右括号的左边分别有多少个左括号
求右括号中 包含着几个完整的括号 (包括自己)
先按照输入构造出原括号
然后匹配下
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#include <set>#include <map>#include <time.h>;#define cler(arr, val) memset(arr, val, sizeof(arr))#define FOR(i,a,b) for(int i=a;i<=b;i++)#define IN freopen ("in.txt" , "r" , stdin);#define OUT freopen ("out.txt" , "w" , stdout);typedef long long LL;const int MAXN = 10014;const int MAXM = 41001;const int INF = 0x3f3f3f3f;const int mod = 1000000007;int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin);#endif int t,n,a; char s[444]; cin>>t; while(t--) { cin>>n; int last=0,tol=0; for(int i=0;i<n;i++) { cin>>a; for(;last<a;last++) s[tol++]='('; s[tol++]=')'; } s[tol]=0; // printf("%s\n",s);//括号 for(int i=0;i<n*2;i++) if(s[i]==')') { int x=1,ans=0; for(int j=i-1;j>=0;j--) { if(s[j]==')') x++; else x--; ans++; if(x==0) break; } printf("%d%c",ans/2+1,i==n*2-1?'\n':' '); } } return 0;}
0 0
- 【瞎搞】 HDU 1361 Parencodings 括号
- hdu 1361 Parencodings
- hdu 1361 Parencodings 模拟
- HDU 1361 Parencodings
- HDU 1361 Parencodings (模拟)
- HDU 1361 & POJ 1068 Parencodings(模拟)
- 【瞎搞】 HDU 1986 Encoding
- 【瞎搞】HDU 5124 lines
- 【瞎搞】 HDU 5312 Sequence
- ZOJ 1016 Parencodings (括号匹配) 思路
- POJ 1068 Parencodings【水模拟--数括号】
- ZOJ 1016 Parencodings (括号配对)
- POJ 1068 Parencodings 模拟-括号匹配
- poj 1086 Parencodings 括号匹配,模拟
- POJ1068 Parencodings(模拟,括号问题)
- HDU 2478 Slides(瞎搞,预处理)
- HDU 4925 Apple Tree (瞎搞)
- HDU 4927 Series 1(瞎搞)
- Java基础-->数组
- error C3130: 内部编译器错误: 未能将插入的代码块写入PDB
- (黑马程序员)intent用法
- 奶牛生子问题(关键字,奶牛,生子,第4年,母牛,每年生一只,20年)
- hibernate之openSession()和getCurrentSession()的区别
- 【瞎搞】 HDU 1361 Parencodings 括号
- 设置win7文件夹背景和图标
- OJ2000题ASCII码排序
- iOS开发autorelease理解
- 01 游戏原理与机制及开发技术
- Objective-c 日期 NSDate 基本够做一个简单的日历
- MySql数据库的基本操作-修改数据表
- cocos2dx3.x 新手打包APK注意事项!
- 297 - Quadtrees