Codeforces 314 E. Sereja and Squares
http://codeforces.com/contest/314/problem/E
题意:
原本有一个合法的括号序列
擦去了所有的右括号和部分左括号
问有多少种填括号的方式使他仍然是合法的括号序列
括号有25种,序列长度<=1e5
传统的做法:
#include<cstdio> using namespace std; #define N 100002 char s[N]; unsigned int f[N<<]; int main()
{
int n;
scanf("%d",&n);
if(n&)
{
putchar('');
return ;
}
scanf("%s",s+);
int m=n>>,q=;
f[]=;
for(int i=;i<=n;++i)
if(s[i]=='?')
for(int j=i>>;j && j>=i-m;--j) f[j]+=f[j-];
else q++;
unsigned int ans=f[m];
for(int i=;i<=m-q;++i) ans*=;
printf("%u",ans);
}
Codeforces 314 E. Sereja and Squares的更多相关文章
- CF 314 E. Sereja and Squares
E. Sereja and Squares http://codeforces.com/contest/314/problem/E 题意: 给你一个擦去了部分左括号和全部右括号的括号序列,括号有25种 ...
- codeforces 314E Sereja and Squares
discription Sereja painted n points on the plane, point number i (1 ≤ i ≤ n) has coordinates (i, 0). ...
- codeforces 425D Sereja and Squares n个点构成多少个正方形
输入n个点,问可以构成多少个正方形.n,xi,yi<=100,000. 刚看题的时候感觉好像以前见过╮(╯▽╰)╭最近越来越觉得以前见过的题偶尔就出现类似的,可是以前不努力啊,没做出来的没认真研 ...
- Codeforces.314E.Sereja and Squares(DP)
题目链接 http://www.cnblogs.com/TheRoadToTheGold/p/8443668.html \(Description\) 给你一个擦去了部分左括号和全部右括号的括号序列, ...
- Codeforces Round #243 (Div. 1)——Sereja and Squares
题目链接 题意: 给n个点,求能组成的正方形的个数. 四边均平行与坐标轴 大神的分析: 经典题 我们考虑每一种x坐标,显然仅仅有<= sqrt{N}个x坐标出现了> sqrt{N}次,我们 ...
- 【codeforces 314C】Sereja and Subsequences
[题目链接]:http://codeforces.com/problemset/problem/314/C [题意] 让你从n个元素的数组中选出所有的不同的非递减子数列; 然后计算比这个子数列小的和它 ...
- 【27.40%】【codeforces 599D】Spongebob and Squares
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces - 367E:Sereja and Intervals(组合数&&DP)
Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. ...
- 【codeforces 367C】Sereja and the Arrangement of Numbers
[题目链接]:http://codeforces.com/problemset/problem/367/C [题意] 我们称一个数列a[N]美丽; 当且仅当,数列中出现的每一对数字都有相邻的. 给你n ...
随机推荐
- effective c++ 笔记 (23-25)
//---------------------------15/04/08---------------------------- //#23 宁以non_member.non_friend替换m ...
- LeetCode 141. Linked List Cycle环形链表 (C++)
题目: Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked ...
- 第五次Scrum meeting
第五次Scrum meeting 会议内容: 连接方面:确定封装成json的文本格式,尽量在满足在线组和手机客户端两组的情况下,降低自身的难度 测试方面:进行新一轮测试,主要测试程序的稳定性和可靠性, ...
- Linux内核分析作业 NO.1
通过汇编一个简单的C程序,分析汇编代码理解计算机是如何工作的 于佳心 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/cour ...
- 【MOOC EXP】Linux内核分析实验四报告
程涵 原创博客 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 [使用库函数API和C代码中嵌入汇编代 ...
- 组件 -- Badge
.badge :长方形的徽章 badge的颜色: .badge-primary .badge-secondary .badge-success .badge-warning ... ... .badg ...
- Maven 学习笔记——Maven环境配置(1)
在学习Selenium的过程中,接触到了Maven(项目管理工具),不至于学一路忘一路,左耳朵进右耳多出,还是决定边学边记录,毕竟听的不如 看的,看的不如写的吗.首先学一样东西,肯定得明确学的是什么, ...
- Sublime Text添加插入带当前时间说明
Sublime Text添加插入带当前时间说明 作者:木尘 日期:2014-11-25 插件实现插入带时间功能的说明: 1. 创建插件: Tools → New Plugin: import da ...
- ThreadLocal 与 Synchronized区别
相同:ThreadLocal和线程同步机制都是为了解决多线程中相同变量的访问冲突问题.不同:Synchronized同步机制采用了“以时间换空间”的方式,仅提供一份变量,让不同的线程排队访问:而Thr ...
- 学习 TTreeView [1] - TTreeNodes、TTreeNode 与 Items、Items.Count、Items.Clear
填写 TTreeView 的内容一般是这样开始的(下图), 不过我觉得最好习惯用动态建立. 打个比方: 譬如 TreeView 是一个军营的"营部"! 这里会有营长.连长.排长.班 ...