Codeforces_723_B
http://codeforces.com/problemset/problem/723/B
求括号内单词数和括号外最大单词长度,注意细心,尤其是ok和sum的置0。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define INF 0x3f3f3f3f
using namespace std; int main()
{
int n;
char s[];
scanf("%d",&n);
getchar();
gets(s);
int maxx = ,cnt = ,flag = ,ok = ,sum = ;
for(int i = ;i < n;i++)
{
if(s[i] == '(')
{
flag = ;
ok = ;
}
else if(s[i] == ')')
{
sum = ;
flag = ;
if(ok) cnt++;
}
else if(flag == )
{
if(s[i] == '_') sum = ;
else
{
sum++;
maxx = max(sum,maxx);
}
}
else if(flag == )
{
if(s[i] == '_')
{
if(ok) cnt++;
ok = ;
}
else ok = ;
}
}
printf("%d %d\n",maxx,cnt);
return ;
}
Codeforces_723_B的更多相关文章
随机推荐
- EF 学习系列二 数据库表的创建和表关系配置(Fluent API、Data Annotations、约定)
上一篇写了<Entity Farmework领域建模方式 3种编程方式>,现在就Code First 继续学习 1.数据库表的创建 新建一个MVC的项目,在引用右击管理NuGet程序包,点 ...
- 15.Python文本转化语音方法
1.用pywin32模块来将文本转化为语音 通过pip install pywin32安装模块,pywin32是个万金油的模块,太多的场景使用到它,但在文本转语音上,它却是个青铜玩家,简单无脑但效果不 ...
- 梳理js数组去重中代码比较简洁的方案
一.es6 Set去重 function removal(arr) { return Array.from(new Set(arr)) } let arr=[1,2,1,3,4,5,5] remova ...
- 转载 css截取td里面的内容 如何固定td th的宽度
源博客地址:http://blog.csdn.net/u011456552/article/details/53839255 效果图: 源码: <!DOCTYPE html> <ht ...
- sg函数的变形 - 可以将一堆石子分开
Nim is a two-player mathematic game of strategy in which players take turns removing objects from di ...
- 《C# 爬虫 破境之道》:第二境 爬虫应用 — 第三节:处理压缩数据
续上一节内容,本节主要讲解一下Web压缩数据的处理方法. 在HTTP协议中指出,可以通过对内容压缩来减少网络流量,从而提高网络传输的性能. 那么问题来了,在HTTP中,采用的是什么样的压缩格式和机制呢 ...
- python 栈
栈的特点:先进后出 class Stack: def __init__(self): self.data = [] def push(self, val): self.data.append(val) ...
- elasticsearch(lucene)索引数据过程
倒排索引存储-分段存储(lucene的功能)在lucene中:lucene index包含了若干个segment在elasticsearch中:index包含了若干主从shard,shard包干了若干 ...
- Ogre3d 1.7.x 的 RTShaderSystem的一个BUG
来源:http://www.ogre3d.org/forums/viewtopic.php?f=2&t=63644 表现:使用dx的shader可能会造成程序崩溃. 在文件OgreShader ...
- Mybatis基础(一)
mybatis概述: MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射.MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集.MyBatis ...