求括号外最长单词长度,和括号里单词个数。

有限状态自动机处理一下。

http://codeforces.com/problemset/problem/723/B

Examples
input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
output
5 4
input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
output
2 6
input
27
(LoooonG)__shOrt__(LoooonG)
output
5 2
input
5
(___)
output
0 0
#include<bits/stdc++.h>
using namespace std;
int a,f,k;
char s[];
int ans1,ans2;
int main(){
scanf("%d %s",&a,s);
for(int i=;s[i];i++){ if(f==){
if(s[i]=='('){
f=;
ans1=max(ans1,k);
k=;
}else if(s[i]=='_'){
ans1=max(ans1,k);
k=;
}else{
k++;
}
}else if(f==){
if(s[i]==')'){
f=;
}else if(s[i]=='_'){ }else if(s[i]<='Z'&&s[i]>='A'||s[i]<='z'&&s[i]>='a'){
f=;
ans2++;
}
}else if(f==){
if(s[i]==')'){
f=;
}else if(s[i]=='_'){
f=;
}
}
}
ans1=max(ans1,k);//wa了一次因为没有计算到最后一个单词。
printf("%d %d",ans1,ans2);
}

  

【Codeforces 723B】Text Document Analysis 模拟的更多相关文章

  1. codeforces 723B Text Document Analysis(字符串模拟,)

    题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...

  2. CodeForces 723B Text Document Analysis (水题模拟)

    题意:给定一行字符串,让你统计在括号外最长的单词和在括号内的单词数. 析:直接模拟,注意一下在左右括号的时候有没有单词.碰到下划线或者括号表示单词结束了. 代码如下: #pragma comment( ...

  3. Codeforces Round #375 (Div. 2) B. Text Document Analysis 模拟

    B. Text Document Analysis 题目连接: http://codeforces.com/contest/723/problem/B Description Modern text ...

  4. Codefoces 723B Text Document Analysis

    B. Text Document Analysis time limit per test:1 second memory limit per test:256 megabytes input:sta ...

  5. codeforces 723B:Text Document Analysis

    Description Modern text editors usually show some information regarding the document being edited. F ...

  6. Text Document Analysis CodeForces - 723B

    Modern text editors usually show some information regarding the document being edited. For example, ...

  7. 【44.10%】【codeforces 723B】Text Document Analysis

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. cf723b Text Document Analysis

    Modern text editors usually show some information regarding the document being edited. For example, ...

  9. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

随机推荐

  1. 转: rapidJSON与jsoncpp语法说明

    转:  http://www.voidcn.com/blog/hudejun007/article/p-1811986.html

  2. 开发之UI篇

    首先这里介绍一个软件一个插件,它们的主要功能是方便开发者看UI(如尺寸,颜色,大小等),两个配合使用 一. Sketch软件 1.Sketch  看ui图,还可以切图 2.Sketch 如何切图: 1 ...

  3. Func<T,TResult>泛型委托

    描述: 封装一个具有一个参数并返回TResult参数指定的类型值的方法. 语法: public delegate TResult Func<T,TResult>(T arg); 参数类型: ...

  4. HTML 学习笔记 CSS3 (2D Matrix)

    Matrix 矩阵 那么什么是矩阵呢? 矩阵可以理解为方阵,只不过 平时方阵里面站着人 矩阵中是数值: CSS3中的矩阵: css3中的矩阵指的是一个方法,书写为matrix() 和 matrix3d ...

  5. Navigator 对象

    Navigator 对象 Navigator 对象包含有关浏览器的信息. 注意: 没有应用于 navigator 对象的公开标准,不过所有浏览器都支持该对象. Navigator 对象属性 属性 说明 ...

  6. C语言:void指针

    使用前必须进行强制类型转换 #include <stdio.h> void test(const void *p); int main(){ ; int *p = &i; puts ...

  7. 多个mapper location时, mybatis spring的自动扫描配置

    1. MapperScannerConfigurer 里面的basePackage, 多个package用逗号分隔 2. SqlSessionFactoryBean里面的mapperLocations ...

  8. facebook graphql

    思想先进,前端直接从后台调用所需要的数据. 最简单的理解: 从"select * from 学生表" 进化为"select name, sex from 学生表" ...

  9. Java集合系列:-----------08HashMap的底层实现

    对于HashMap感觉一直是看了忘,忘了看.这里就单独写一篇日志来记录一下.HashMap的底层实现. 非常好的讲HashMap的博客:http://blog.csdn.net/vking_wang/ ...

  10. 小tips: 使用&#x3000;等空格实现最小成本中文对齐

    一.重见天日第二春 11年的时候,写了篇文章“web页面相关的一些常见可用字符介绍”,这篇文章里面藏了个好东西,就是使用一些空格实现个数不等的中文对齐或等宽.见下表: 字符以及HTML实体 描述以及说 ...