您当前的位置: 首页 > 

先求一个导

暂无认证

  • 1浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

牛客手速月赛45 D(合法括号序列模板不会有人不会敲叭,指自己)

先求一个导 发布时间:2022-03-04 21:57:29 ,浏览量:1

题目 题意: 给定括号序列,可以切任意刀,求有多少个方案可以使得切完以后剩余每个部分都是合法的括号序列。 思路: 假设有n个间隙隔开了合法的括号序列,有n-1个可选择的位置用来切割。2^n种方案。实时维护一下括号序列是否合法即可。若有0个间隙,说明寄,无解。考察合法括号序列模板. 时间复杂度: O(n) 代码:

// Problem: 切糕
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/11222/D
// Memory Limit: 524288 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i>= 1;
	}
	return res;
}
void solve()
{
   scanf("%s",s+1);
   n = strlen(s+1);
   stack st;
   int tot = 0;
   bool flag = true;
   for(int i=1;i>T;
   // read(T);
   while(T--)
   {
   	 solve();
   }
   return 0;
}

关注
打赏
1662037414
查看更多评论
立即登录/注册

微信扫码登录

0.0381s