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 ...
随机推荐
- 【RDB】MariaDB 之事务、复制、集群
目录 简介 安装启动 权限 事务 脏读.不可重复读.幻读 MVCC 复制 异步复制 半同步复制 GTID复制 集群(Galera) 配置 监控(Zabbix) 简介 环境: CentOS 7.4.17 ...
- LeetCode 3Sum (Two pointers)
题意 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all ...
- 一个Python开源项目-腾讯哈勃沙箱源码剖析(上)
前言 2019年来了,2020年还会远吗? 请把下一年的年终奖发一下,谢谢... 回顾逝去的2018年,最大的改变是从一名学生变成了一位工作者,不敢说自己多么的职业化,但是正在努力往那个方向走. 以前 ...
- Flask_admin 笔记一 (快速启用)
1,快速启用 1) 安装flask-admin pip install flask-admin 2) 配置使用 from flask import Flask from flask_admin i ...
- 基于.NET Standard的分布式自增ID算法--美团点评LeafSegment
概述 前一篇文章讲述了最流行的分布式ID生成算法snowflake,本篇文章根据美团点评分布式ID生成系统文章,介绍另一种相对更容易理解和编写的分布式ID生成方式. 实现原理 Leaf这个名字是来自德 ...
- 【Direct2D1.1初探】Direct2D特效概览
转载请注明出处:http://www.cnblogs.com/Ray1024 一.概述 Direct2D是一个基于Direct3D的2D图形API,可以利用硬件加速特性来提供高性能高质量的2D渲染.但 ...
- 虚拟机console基础环境部署——工作目录准备
1. 概述2. 相关约定2.1 删除旧文件2.2 创建全局共享文件目录2.3 创建全局软件安装目录2.4 创建数据放置目录3. 总结 1. 概述 上述博客中,已经为console最小化安装了操作系统. ...
- Day Two
站立式会议 站立式会议内容总结 442 完成了计划列表和toolbar的事件监听部分 遇到问题:父组无法实现事件监听,只能实现点击折叠.展开的功能. 331 学习form中list数据添加 遇到的问题 ...
- Linux命令(二十) 显示系统内存状态 free
一.命令简介 free 命令会显示内存的使用情况,包括实体内存,虚拟的交换文件内存.共享内存区段,以及系统核心使用的缓冲区等. 二.参数说明 -b 以Byte为单位显示内存使用情况 -K 以KB为单位 ...
- 2019 front-end web trending
2019 front-end web trending https://github.com/kamranahmedse/developer-roadmap https://raw.githubuse ...