Codeforces Round #375 (Div. 2) B
来源:互联网 发布:安卓手机修图软件 编辑:程序博客网 时间:2024/05/16 18:59
题意:
询问括号内有多少个单词,括号外最长的单词长度
#include <iostream>#include <stdio.h>#include <algorithm>using namespace std;char a[1000];int main(){ int n; cin>>n; getchar(); for(int i=1;i<=n;i++) cin>>a[i]; int flag=0; int maxw=0; int maxn=0; int zz=0; int tepw=0; int tepn=0; for(int i=1;i<=n;i++) { if(a[i]=='_') { if(i!=1) { if(a[i-1]!='_'&&a[i-1]!=')'&&a[i-1]!='(') { if(zz==0) { maxw=max(maxw,tepw); tepw=0; } else tepn++; } } } else if(a[i]=='(') { if(i!=1&&a[i-1]!='_'&&a[i-1]!=')') if(zz==0) { maxw=max(maxw,tepw); tepw=0; } zz++; } else if(a[i]==')') { if(a[i-1]!='_'&&a[i-1]!='(') { tepn++; } zz--; } else { if(zz==0) tepw++; } } if(a[n]!='_'&&a[n]!='('&&a[n]!=')') { maxw=max(maxw,tepw); } cout<<maxw<<" "<<tepn<<endl; return 0;}
0 0
- Codeforces Round #375 (Div. 2) B
- Codeforces Round #375 (Div. 2)【A,B【模拟】,D【DFS】】
- Codeforces Round #375 (Div. 2)B. Text Document Analysis
- Codeforces Round #375 (Div. 2) A&B&C
- Codeforces Round #375 (Div. 2)B. Text Document Analysis
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #171 (Div. 2) B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #192 (Div. 2) B
- Codeforces Round #203 (Div. 2) B. Resort
- Codeforces Round #206 (Div. 2) - b
- Codeforces Round #202 (Div. 2)B-贪心
- 初识 gradle
- 别轻易自责,专注力和自制力是稀缺资源
- Cards
- CNKI PDF全文下载脚本
- win10更新后ChsIME CPU使用率高
- Codeforces Round #375 (Div. 2) B
- 已有Android,谷歌又开发新系统Fuchsia,意欲何为
- Medium 200题 Number of Islands
- 自动提示宏--输入什么属性,就把属性自动生成OC字符串
- 【管理者】精读德鲁克教授《卓有成效的管理者》<一>
- nginx是以多进程的方式来工作的
- TensorFlow 简介
- 微信【接收普通消息】
- Java之final关键词详解