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

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

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. uva10001 Garden of Eden

    Cellular automata are mathematical idealizations of physical systems in which both space and time ar ...

  2. jsonobject 遍历 org.json.JSONObject

    import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public static  ...

  3. UIScrollView解决无法触发手势

    //创建一个分类 //.h #import <UIKit/UIKit.h> @interface UIScrollView (Touch) - (void)touchesBegan:(NS ...

  4. 用Metasploit破解Mysql用户名和密码

    下面这个方式是普适的,但缺点就是必须要有自己的用户名和密码字典.其原理就是用user.txt与pass.txt的两个文本去不停交叉验证. msf auxiliary(mysql_login) > ...

  5. ASP.NET MVC验证 - 自定义验证规则、验证2个属性值不等【待验证】

    提示:保存后才提示错误信息 自定义验证特性,继承ValidationAttribute并实现IClientValidatable 这次重写了基类的IsValid()方法的另外一个重载,因为该重载包含了 ...

  6. 【MySql】存储过程添加事务

    存储过程使用SQLException捕获SQL错误,然后处理: 我们可以在MySQL存储过程中捕获SQL错误,然后通过事务判断,回滚(ROLLBACK)还是提交(COMMIT). CREATE PRO ...

  7. vue 滚动加载

    <template> <div class="wraper" @scroll="onScroll($event)"> <div c ...

  8. jQuery学习笔记(二):this相关问题及选择器

    上一节的遗留问题,关于this的相关问题,先来解决一下. this的相关问题 this指代的是什么 这个应该是比较好理解的,this就是指代当前操作的DOM对象. 在jQuery中,this可以用于单 ...

  9. web安全——代理(nginx)

    场景 过滤非正常用户使用的http请求. 限制正常用户使用的范围(下载速度.访问频率等). 通过架构规划来提升安全. 能自动解决http请求问题. 解决方案 代理自身的安全 千万不要使用root启动! ...

  10. sql server 事务处理

    事物处理   事务是SQL Server中的单个逻辑单元,一个事务内的所有SQL语句作为一个整体执行,要么全部执行,要么都不执行. 事务有4个属性,称为ACID(原子性.一致性.隔离性和持久性)   ...