CodeForces1214C
是个不是很难的题目.
首先考虑如果左右括号数量不匹配那么肯定无论如何都不能通过移动一个括号完成匹配.
否则,我们考虑,将所有匹配的括号都去掉,剩下的括号只要大于\(2\)个,就不可能,否则就可以.
需要注意的是,剩下的左右括号都要算.
\(Code:\)

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = a ; i <= b ; ++ i)
#define per(i,a,b) for (int i = a ; i >= b ; -- i)
#define pii pair < int , int >
#define X first
#define Y second
#define rint read<int>
#define int long long
#define pb push_backusing std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::swap ;
using std::sort ;
using std::unique ;
using std::greater ;template < class T >inline T read () {T x = 0 , f = 1 ; char ch = getchar () ;while ( ch < '0' || ch > '9' ) {if ( ch == '-' ) f = - 1 ;ch = getchar () ;}while ( ch >= '0' && ch <= '9' ) {x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;ch = getchar () ;}return f * x ;
}template < class T >inline void write (int x) {static T stk[100] , top = 0;if (x == 0) { putchar ('0') ; return ; }if (x < 0) { x = - x ; putchar ( '-' ) ; }while (x) { stk[++top] = x % 10 ; x /= 10 ; }while (top) { putchar ( stk[top--] + '0') ; }}const int N = 2e5 + 100 ;int n , cnt , num ; char s[N] ;signed main (int argc , char * argv[]) {n = rint () ; scanf ("%s" , s + 1 ) ;rep ( i , 1 , n ) num += ( s[i] == '(' ) ;if ( num != n - num ) { puts ("No") ; return 0 ; }num = 0 ;rep ( i , 1 , n )if ( s[i] == '(' ) ++ cnt ;else { if ( cnt ) -- cnt ; else ++ num ; }if ( cnt + num > 2 ) puts ("No") ; else puts ("Yes") ;return 0 ;
}

转载于:https://www.cnblogs.com/Equinox-Flower/p/11469115.html

CodeForces1214C相关推荐

最新文章

  1. 如何为ccflow工作流引擎增加一个优先级PRI?
  2. PICRUSt:16S预测宏基因组-扩增子分析锦上添花
  3. 生产订单新增按钮没权限
  4. 在html中怎么在按回车的时候换到下一个文本框_史上最全的HTML、CSS知识点总结,浅显易懂。适合入门新手...
  5. 和法国的剑桥创业老哥的沟通让我发现了很神奇的点
  6. oracle 一张表插入另外一张表 存储过程
  7. Shiro过滤器源码
  8. Robot Framework-Ride界面介绍及库的添加
  9. java中如何运行小程序_一起学java(一)——运行第一个小程序
  10. NeurlPS 2019丨微软亚洲研究院 5 篇精选论文解读
  11. Java IO之File类详解
  12. L3-009 长城 (30 分)-PAT 团体程序设计天梯赛 GPLT
  13. linux远程控制本地用户登录,linux 本地无法登录 远程可以登陆的解决办法
  14. 计算机九针孔什么接口,db9接口-USBCAN-I设备的DB9针串口头中的针脚是如何定义的-电气资讯 - 电工屋...
  15. java优先级 六级和七级_百度知道六级和七级得区别是什么?如何升到七级?
  16. IOI2021 国家集训队作业部分题解
  17. 技术设计的任务是将功能原理方案得以具体化
  18. Axure images 元件,图片在浏览器加载不出来
  19. Mysql基础篇(3)—— MySQL数据库类型
  20. 货币金融学(1): 货币/ 信用/ 金融机构

热门文章

  1. OpenCV 形态学操作之腐蚀与膨胀,开运算与闭运算,顶帽与黑帽,图像梯度运算相关知识点回顾
  2. VQA系列论文(四)
  3. Python学习八:数据库编程接口
  4. 工作...工作...工作...
  5. 2022-2027年中国汽车传感器行业市场调研及未来发展趋势预测报告
  6. 【IAR】IAR for MSP430添加头文件的方法
  7. angular4 使用HttpClient拦截器 检查token失效,返回登录页面
  8. VS2017的C#语言与matlab2014A的m语言混合编程的方法
  9. c语言程序中函数调用本身叫什么,在C语言中函数调用方式有什么区别
  10. python深度学习之TCN实例