【Codeforces 723B】Text Document Analysis 模拟
求括号外最长单词长度,和括号里单词个数。
有限状态自动机处理一下。
http://codeforces.com/problemset/problem/723/B
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
5 4
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
2 6
27
(LoooonG)__shOrt__(LoooonG)
5 2
5
(___)
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 模拟的更多相关文章
- codeforces 723B Text Document Analysis(字符串模拟,)
题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...
- CodeForces 723B Text Document Analysis (水题模拟)
题意:给定一行字符串,让你统计在括号外最长的单词和在括号内的单词数. 析:直接模拟,注意一下在左右括号的时候有没有单词.碰到下划线或者括号表示单词结束了. 代码如下: #pragma comment( ...
- Codeforces Round #375 (Div. 2) B. Text Document Analysis 模拟
B. Text Document Analysis 题目连接: http://codeforces.com/contest/723/problem/B Description Modern text ...
- Codefoces 723B Text Document Analysis
B. Text Document Analysis time limit per test:1 second memory limit per test:256 megabytes input:sta ...
- codeforces 723B:Text Document Analysis
Description Modern text editors usually show some information regarding the document being edited. F ...
- Text Document Analysis CodeForces - 723B
Modern text editors usually show some information regarding the document being edited. For example, ...
- 【44.10%】【codeforces 723B】Text Document Analysis
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- cf723b Text Document Analysis
Modern text editors usually show some information regarding the document being edited. For example, ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
随机推荐
- HTML 学习笔记 CSS3(Animation)
CSS3动画: 通过CSS3 我们能够创建动画 这可以在许多网页中取代动画图片 Flash动画 以及JavaScript. CSS3 @keyframes 规则如需在 CSS3 中创建动画,您需要学习 ...
- js获取样式的兼容写法
var currentStyle = function(element){ return element.currentStyle || document.defaultView.getCompute ...
- js物理弹性窗口
js物理弹性窗口 点击下载代码
- delphi附带通用控件安装方法:
附带通用控件安装方法:----------基本安装1.对于单个控件,Componet-->install component..-->PAS或DCU文件-->install;2.对于 ...
- matlab:启动后无法调用工具包
matlab有时候一打开会出现warning,然后任何工具包(包括set path)都执行不了,在网上找到解决方法,存下来备用. 1. 在matlab的command里输入: restoredefau ...
- MVC中如何设置路由指定默认页
MVC中怎么设置默认页,在webform中 只要右键设置起始页就可以,但MVC中却没有这个功能,其实MVC更简单 如下: Login是控制器,Index 是动作 在全局Global.asax中改动下即 ...
- Castle ActiveRecord 二级缓存使用 异常记录
在 本公司的 IBeamMDAA 框架下,如果是配置为本机调试时,AR的查询缓存工作正常,但如果部署到服务器上,工作不正常,二级缓存配置为使用 MemoryCahcheD 服务器,二级缓存没有能够根据 ...
- UIScrollView增加刷新
1. if (!self.scrollView) { CGRect frame = CGRectMake(0.0, 0.0, CGRectGetWidth(self.view.frame), CGRe ...
- mssql 2008 复制订阅
广域网的复制订阅 准备工作: 1.a.b服务器创建相同的系统用户密码 2.在a服务器 sql server 配置管理器 创建别名 ip填写b服务器的ip, b服务器端口号 3.在b服务器 sql s ...
- codevs 2651 孔子教学——同桌
2651 孔子教学--同桌 题目描述 Description 孔子是我国古代著名的教育家.他有先见之明,可以判断学生出师以后给他带来的声望.声望共有三种"G""M&quo ...