Codeforces Round #375 (Div. 2) B. Text Document Analysis(字符串处理,简单题目)
来源:互联网 发布:端口在线扫描 编辑:程序博客网 时间:2024/06/06 01:07
题目链接:http://codeforces.com/contest/723/problem/B
【分析】求不在括号里的单词的长度和在括号里的单词的个数。立个flag表示所处状态就好了,0表示不在括号内,1表示在括号内,然后再扫一遍就OK了。
下面是AC代码:
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;char a[355];int main(){ int n; while(~scanf("%d",&n)) { scanf("%s",a); int len=strlen(a); int s1=0,s2=0,flag=0,maxn=0; for(int i=0;i<len;i++) { if(a[i]!='_'&&a[i]!='('&&a[i]!=')'&&flag==0) { s1++; maxn=max(maxn,s1); } if(a[i]=='_') { s1=0; } if(a[i]=='(') { flag=1; s1=0; } if(a[i]!='_'&&a[i]!='('&&a[i]!=')'&&(a[i+1]=='_'||a[i+1]=='('||a[i+1]==')')&&flag==1) { s2++; s1=0; } if(a[i]==')'&&flag==1) { flag=0; s1=0; } } printf("%d %d\n",maxn,s2); } return 0;}
0 0
- Codeforces Round #375 (Div. 2) B. Text Document Analysis(字符串处理,简单题目)
- Codeforces Round #375 (Div. 2)B. Text Document Analysis
- Codeforces Round #375 (Div. 2)B. Text Document Analysis
- Codeforces Round #375 (Div. 2) B.Text Document Analysis(分类暴力)
- Text Document Analysis Codeforces Round#375-B
- 【Codeforces Round 375 (Div 2) B】【水模拟】Text Document Analysis
- Codeforces 723B Text Document Analysis (字符串处理)
- Codeforces #375(Div.2)B.Text Document Analysis【模拟】水题
- CodeForces 723B Text Document Analysis(字符串的分析)
- Codeforces Round #375 Text Document Analysis
- B. ZgukistringZ-简单字符串处理-Codeforces Round #307 (Div. 2)
- Codeforces Round #239 (Div. 2) B. Garland(字符串统计题目,简单题)
- CodeForces 723B-Text Document Analysis(模拟)
- [codeforces] B. Text Document Analysis 字符分析
- 【44.10%】【codeforces 723B】Text Document Analysis
- Codeforces 723 B. Text Document Analysis
- Codeforces 723B Text Document Analysis
- CodeForces 723B Text Document Analysis
- 面向对象多态之接口
- 关于问题short s1 = 1; s1 = s1 + 1;出现编译错误,而 short s1 = 1; s1 += 1;不出现编译错误。
- 回调函数
- ios利用短信SKD实现短信验证(使用mob网站提供的免费接口)
- 找到含有n个不同字符的子串的最大长度
- Codeforces Round #375 (Div. 2) B. Text Document Analysis(字符串处理,简单题目)
- java与mysql
- 投资分析框架
- 10.2弱校题解
- [LeetCode]--136. Single Number
- 【微信开发】-发送位置获取周边信息, 主要代码在private function receiveLocation($object)
- 括号匹配
- springmvc请求问题
- CSS3利用@font-face使用自定义字符和图标