当前位置: 首页 > news >正文

P3056 [USACO12NOV] Clumsy Cows S

[USACO12NOV] Clumsy Cows S

题目描述

Bessie the cow is trying to type a balanced string of parentheses into her new laptop, but she is sufficiently clumsy (due to her large hooves) that she keeps mis-typing characters. Please help her by computing the minimum number of characters in the string that one must reverse (e.g., changing a left parenthesis to a right parenthesis, or vice versa) so that the string would become balanced.

There are several ways to define what it means for a string of parentheses to be “balanced”. Perhaps the simplest definition is that there must be the same total number of ('s and )'s, and for any prefix of the string, there must be at least as many ('s as )'s. For example, the following strings are all balanced:

()
(())
()(()())

while these are not:

)(
())(
((())))

给出一个偶数长度的括号序列,问最少修改多少个括号可以使其平衡。

输入格式

* Line 1: A string of parentheses of even length at most 100,000 characters.

输出格式

* Line 1: A single integer giving the minimum number of parentheses that must be toggled to convert the string into a balanced string.

样例 #1

样例输入 #1

())(

样例输出 #1

2

提示

The last

http://www.lryc.cn/news/378600.html

相关文章:

  • 智赢选品,OZON数据分析选品利器丨萌啦OZON数据
  • Canal自定义客户端
  • 20240621将需要自启动的部分放到RK3588平台的Buildroot系统的rcS文件中
  • 掌握数据魔方:Xinstall引领ASA全链路数据归因新纪元
  • IIS代理配置-反向代理
  • Flutter调用本地web
  • AI大模型部署Ubuntu服务器攻略
  • vlan、vxlan、vpc学习
  • 低代码开发:加速工业数智化转型发展
  • python“__main__“的解读
  • Linux Debian12使用podman安装pikachu靶场环境
  • 跑通并使用Yolo v5的源代码并进行训练—目标检测
  • 需求虽小但是问题很多,浅谈JavaScript导出excel文件
  • phar反序列化及绕过
  • 汽车IVI中控开发入门及进阶(三十):视频图像滚动问题分析(imx6+TVP5150+Camera)
  • 给PDF添加书签的通解-姜萍同款《偏微分方程》改造手记
  • 在寻找电子名片在线制作免费生成?5个软件帮助你快速制作电子名片
  • Github 2024-06-16 php开源项目日报 Top10
  • docker将容器打包提交为镜像,再打包成tar包
  • 洛阳水利乙级资质企业在水利科技创新中的作用
  • Redis-事务-基本操作-在执行阶段出错不会回滚
  • aws的alb,多个域名绑定多个网站实践
  • WPF/C#:数据绑定到方法
  • GBDT算法详解
  • 51单片机宏定义的例子
  • 香港云服务器怎么处理高并发和突发流量?
  • c,c++,qt从入门到地狱
  • iptables(6)扩展匹配条件--tcp-flags、icmp
  • C#-Json文件的读写
  • 【2023级研究生《人工智能》课程考试说明】