• CF 917A The Monster 【括号匹配】


    【链接】:CF

    Examples
    inputCopy
    ((?))
    outputCopy
    4
    inputCopy
    ??()??
    outputCopy
    7
    
    说明
    For the first sample testcase, the pretty substrings of s s are:
    
    "(?" which can be transformed to "()".
    "?)" which can be transformed to "()".
    "((?)" which can be transformed to "(())".
    "(?))" which can be transformed to "(())".
    For the second sample testcase, the pretty substrings of s s are:
    
    "??" which can be transformed to "()".
    "()".
    "??()" which can be transformed to "()()".
    "?()?" which can be transformed to "(())".
    "??" which can be transformed to "()".
    "()??" which can be transformed to "()()".
    "??()??" which can be transformed to "()()()".
    

    【题意】:
    给你一个字符串只包含'(' 、‘ )’ 、‘ ?’三种字符,?你可以按需求转换成‘(’或’)‘
    定义一个区间为正确的括号序列,当且仅当对该区间进行如下操作之后,该序列为空:每次删除序列中一对相邻的左右括号(),直到删到不能再删
    Input
    一个长度不超过5000的字符串
    Output
    能转换成正确的括号序列的子区间数量
    【分析】:
    【代码】:

  • 相关阅读:
    zookeeper安装教程
    CentOS7服务管理(重启,停止,自动启动命令)
    redis配置文件详解
    阿里云 CentOS7安装redis4.0.9并开启远程访问
    rpm命令
    wget命令
    yum命令
    maven项目debug调试不能够进入源码问题解决
    8-字符串
    7-数组
  • 原文地址:https://www.cnblogs.com/Roni-i/p/9215580.html
Copyright © 2020-2023  润新知