Nowadays emoticon has become an art. People are no longer limited to simple ones like

‘:-)’, ‘:-(’,‘:-P’, etc. They use ‘>:O’, ‘~_~’, ‘=^_^=’

and so on. Recently I came across ‘^_^’ and it looks kind of cute to me. Given a string S consisting of only ‘_’s and ‘^’s, I was wondering what is the maximum number of disjoint subsequences of “^_^” (quote for beauty) in the string S.
    For example, if S = “^^__^^” then the answer is 2. However, for S = “_^^” the answer is 0.

Input
Input starts with a positive integer T (≤ 5, 000), denoting the number of test cases. Hence follows T test cases. Each case consists of a single string made of only ‘^’ and ‘_’. The length of the strings would be at most 100,000 and the sum of lengths of the strings will be 2,100,000 at most.
Output
For each test case, print the case number followed by the answer.
Hint:
• S[1…n] means S is a string of length n and it is 1-indexed.
• Si means i’th character of S.
• A string S[1…n] is a subsequence of another string T[1…m], if we can find: (t1, t2, . . . , tn) such that, S[i] = T[ti] for 1 ≤ i ≤ n and 1 ≤ t1 < t2 < . . . < tn ≤ m. For example, ‘abc’ is a subsequence of ‘aabbcc’ but not of ‘bca’.
• Two subsequences are disjoint if same character (position matters) is not used in both of the subsequences. For example, let S = ‘abca’. ‘ab’ and ‘ca’ are two disjoint subsequences of S. However, if S = ‘abc’ then ‘ab’ and ‘ac’ are not disjoint subsequences. In both of these examples the subsequences are unique. However, for S = ‘aabb’ let’s form two subsequences S1S3 and S2S4 (both are ‘ab’), both of these are disjoint. But if we have chosen S1S3 and S1S4 then they would not be disjoint.
Sample Input

5
_^^_^^_
^__^__^
______
^^__^^
^_^^_^

Sample Output
Case 1: 1
Case 2: 1
Case 3: 0
Case 4: 2
Case 5: 2

问题链接:UVA13029 Emoticons
问题简述:(略)
问题分析:文本处理问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA13029 Emoticons */#include <bits/stdc++.h>using namespace std;const int N = 100000 + 1;
char s[N];int main()
{int t;scanf("%d", &t);for (int k = 1; k <= t; k++) {scanf("%s", s);int ans = 0, h1 = 0, h2 = 0, h3 = 0;for (int i = 0; s[i]; i++) {if (s[i] == '^') {if (h2) h2--, ans++;else if (h3 && ans) h2++, h3--;else h1++;} else if(s[i] == '_') {if (h1) h1--, h2++;else if (ans > h3) h3++;}}printf("Case %d: %d\n", k, ans);}return 0;
}

UVA13029 Emoticons【文本处理】相关推荐

  1. java富文本编辑器KindEditor

    在页面写一个编辑框: <textarea name="content" class="form-control" id="content&quo ...

  2. 富文本框让最大四百像素_TinyMCE 富文本编辑器 ━━ 基本配置

    基本配置 在对 TinyMCE 配置的介绍中,我们将讨论基于传统表单的布局中通常使用的最重要的选项,以及如何将 TinyMCE 用作内联编辑器的示例. 将 TinyMCE 脚本添加到页面后,需要考虑三 ...

  3. 富文本编辑器 java_Java开发之富文本编辑器TinyMCE

    一.题外话 最近负责了一个cms网站的运维,里面存在很多和编辑器有关的问题,比如编辑一些新闻博客,论文模块.系统采用的是FCKEditor,自我感觉不是很好,如下图 特别是在用户想插入一个图片的话,就 ...

  4. kindEditor富文本编辑器的工具栏设置

    如何配置kindeditor的工具栏 kindeditor编辑器的工具栏主要是指编辑器输入框上方的那些可以操作的菜单,默认情况下编辑器是给予了所有的工具栏.针对不同的用户,不同的项目,不同的环境,可能 ...

  5. 浏览器中插入富文本编辑器

    常用的富文本编辑器有CKEditor.UEEditor.TinyEditor.KindEditor等.以下以kindeditor编辑器的使用为例. 1.官网下载KindEditor编辑器http:// ...

  6. html编辑器查找与替换,织梦kindeditor文本编辑器增加“查找替换”功能

    织梦kindeditor文本编辑器增加"查找替换"功能效果演示 1.items 里面增加 search 按钮 ['source','|','undo','redo','|','pr ...

  7. 一步步教你实现富文本编辑器(第四部分)

    这部分我将详尽讲述如何插入复杂的html内容与取得编辑光标的位置,顺带完成插入表情的功能.由于IE与FF这两个闹别扭,这两步的实现都是完全不一样的.不说废话了!开始吧! 上次我们已经为我们的富文本编辑 ...

  8. 富文本编辑器KindEditor在前端JS的应用

    1.引入KindEditor资源包 2.页面引入Js,Css文件 3.html代码: <tr><td class="left">讲师信息</td> ...

  9. tinymce 富文本简单使用

    tinymce.init({ //选择器 selector:'textarea', //配置顶部的菜单栏显示隐藏 menubar: false, //配置中文(默认没有中文包,需要到官网下载,放到la ...

最新文章

  1. AndroidのUI设计研究(一)——自定义ProgressBar
  2. 【Java 虚拟机原理】Java 类中的类加载初始化细节 ( 只使用类中的常量时加载类不会执行到 ‘初始化‘ 阶段 )
  3. 利用vue v-bind属性绑定bootstrap样式以及输出数据
  4. QT输入输出(四)之 QProcess
  5. centos7.1下的mariadb数据库数据出现不支持中文问题
  6. spring 整合websocket过程中遇到的问题
  7. 跟踪某个类所创建对象的个数
  8. ASC加密解密(笔记)
  9. 机器学习(3)——有监督学习
  10. 纵横捭阖 《鬼谷子》
  11. css 大于号 标签_css选择器 ~ (波浪号)、+(加号)、(大于号)的用法解析和举例...
  12. 2023北京国际老年产业博览会/养老产业展/养老服务业展
  13. 计算机网络-自顶向下方法-笔记【第1章-概述】
  14. Win10系统 IE11浏览器调用F12开发人员工具,打开后底部显示空白
  15. Eclipse中调试Python代码--调试FWTools2.4.7中的gdal_retile.py
  16. obs多推流地址_微信小程序直播电脑端OBS推流直播教程
  17. [2021.10.30][uml]UML顺序图规范
  18. 电脑ftp服务器信息,电脑上的ftp信息服务器地址
  19. android界面不显示,Android 可视化界面编辑器无法显示界面问题的终极解决方案
  20. Nachos系统调用的实现

热门文章

  1. 本科、硕士、博士的区别
  2. ArcGIS Portal 10.4 本地坐标系的web 3d地形展示制作说明
  3. 快速开发框架介绍-懂你的RUOYI
  4. Dreamweaver CS5.5+PhoneGap移动开发环境搭建
  5. 【数据结构的魅力】001.认识复杂度二分法异或运算
  6. linux 脚本 if then,shell学习之if-then语法
  7. JavaScript(四)字符串类型
  8. java用来存储键值的容器是_Java容器 - osc_y0caef0i的个人空间 - OSCHINA - 中文开源技术交流社区...
  9. vba excel 取得chart保存图片_保存Excel中的图片
  10. Tensorflow——add_layer(添加神经层)