当前位置: 首页 > 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

相关文章:

  • 智慧园区数字化能源云平台的多元化应用场景,您知道哪些?
  • 虚拟专用网络 之 VPN
  • 国有企业数字化转型常见思考框架与路线图
  • golang中的内存缓存如何避免被GC扫描,BigCache实现原理
  • 浅谈微服务架构中实现单点登录
  • WHAT - HTTP keep-alive 持久性连接和内存泄漏问题
  • 何在 Vue3 中使用 Cytoscape.js 创建交互式网络图
  • 前端面试题(六)答案版
  • 内网安全[3]-代理Socks协议路由不出网后渗透通讯CS-MSF控制上线
  • 跨境电商的大麻烦——黑客攻击
  • 数据中心:AI范式下的内存挑战与机遇
  • 神经网络的卷积操作中不同的卷积核和不同的填充获得同样的输出
  • 【Linux】进程信号2——阻塞信号,捕捉信号
  • Serverless如何赋能餐饮行业数字化?乐凯撒思变之道
  • C++ Day1
  • CentOS学习笔记 - 12. Nginx搭建Centos7.5远程repo
  • Java知识点总结(JavaIO-打印流)
  • Python 基础起步 (十) 什么叫函数?
  • Vue.js 移动端适配之 vw 解决方案
  • win10下安装mysql5.7
  • 基于 Ueditor 的现代化编辑器 Neditor 1.5.4 发布
  • 基于MaxCompute打造轻盈的人人车移动端数据平台
  • 前端性能优化--懒加载和预加载
  • 找一份好的前端工作,起点很重要
  • No resource identifier found for attribute,RxJava之zip操作符
  • ​​​​​​​开发面试“八股文”:助力还是阻力?
  • ​ssh免密码登录设置及问题总结
  • # 数仓建模:如何构建主题宽表模型?
  • (160)时序收敛--->(10)时序收敛十
  • (2)Java 简介
  • (2024)docker-compose实战 (9)部署多项目环境(LAMP+react+vue+redis+mysql+nginx)
  • (cos^2 X)的定积分,求积分 ∫sin^2(x) dx
  • (附源码)ssm跨平台教学系统 毕业设计 280843
  • (十二)python网络爬虫(理论+实战)——实战:使用BeautfulSoup解析baidu热搜新闻数据
  • (详细版)Vary: Scaling up the Vision Vocabulary for Large Vision-Language Models
  • (一)硬件制作--从零开始自制linux掌上电脑(F1C200S) <嵌入式项目>
  • (原創) 是否该学PetShop将Model和BLL分开? (.NET) (N-Tier) (PetShop) (OO)
  • .gitignore文件使用
  • .NET 4.0中使用内存映射文件实现进程通讯
  • .NET 8 编写 LiteDB vs SQLite 数据库 CRUD 接口性能测试(准备篇)
  • .net CHARTING图表控件下载地址
  • .NET CORE Aws S3 使用
  • .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划
  • .net mvc 获取url中controller和action
  • .NET 中小心嵌套等待的 Task,它可能会耗尽你线程池的现有资源,出现类似死锁的情况
  • .net连接oracle数据库
  • .secret勒索病毒数据恢复|金蝶、用友、管家婆、OA、速达、ERP等软件数据库恢复
  • ??eclipse的安装配置问题!??
  • @Not - Empty-Null-Blank
  • @SuppressLint(NewApi)和@TargetApi()的区别
  • [000-01-022].第03节:RabbitMQ环境搭建
  • [2024] 十大免费电脑数据恢复软件——轻松恢复电脑上已删除文件
  • [BJDCTF2020]The mystery of ip
  • [BZOJ 4598][Sdoi2016]模式字符串
  • [C#] 基于 Token 的鉴权与签名机制详解 接口对接鉴权 token、sign(a=1b=2c=3d=4)、Base64、参数加密、MD5