【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 ...
随机推荐
- Volley(二)—— 基本Request对象 & RequestQueue&请求取消
详细解读Volley(一)—— 基本Request对象 & RequestQueue&请求取消 Volley它非常适合去进行数据量不大,但通信频繁的网络操作,而对于大数据量的网络操作, ...
- 《JavaScript基础教程》
第五章.窗口与框架 5.2 设置目标 源代码: //主页面:Captain.html <!DOCTYPE html> <html lang="en" xmlns= ...
- grunt-contrib-uglify压缩插件的常用配置属性
mangle:false(不混淆变量名和方法名,保留原有的名字),如果不配置,默认混淆,就是将所有方法名和变量都用a,b,c等字母替换 preserveComments : 'all'(不删除注释,还 ...
- IOS-利用AFNetworking监听网络状态
网络环境检测:检测用户当前所处的网络状态 效果图 1.当蜂窝和wifi同时关闭时候 显示为不可达(AFNetworkReachabilityStatusNotReachable)状态 2.打开蜂窝移 ...
- 51nod lyk与gcd
1678 lyk与gcd 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 这天,lyk又和gcd杠上了.它拥有一个n个数的数列,它想实现两种操作. 1:将 ai ...
- adb 常用命令
1.adb shell dumpsys SurfaceFlinger 查看window层结构
- usb驱动开发21之驱动生命线
现在开始就沿着usb_generic_driver的生命线继续往下走.设备的生命线你可以为是从你的usb设备连接到hub的某个端口时开始,而驱动的生命线就必须得回溯到usb子系统的初始化函数usb_i ...
- 将函数传给webworker
var zWorker = function (func,cb){ var node = document.createElement('script'),workerId='worker' + Da ...
- Eclipse使用Maven构建web项目
1.创建Maven项目: 点击“File”菜单,或者通过工具栏的“New”创建Project,如下图所示: 选择Maven->Maven Project,弹出向导对话框,如下图所示: 选中Cre ...
- <实训|第十一天>学习一下linux中的进程,文件查找,文件压缩与IO重定向
[root@localhost~]#序言 在今后的工作中,运维工程师每天的例行事务就是使用free -m,top,uptime,df -h...每天都要检查一下服务器,看看是否出现异常.那么今天我们就 ...