zoukankan      html  css  js  c++  java
  • 【小米oj】 括号配对

    堆栈的基本应用

     1 #define mm(a) memset(a,0,sizeof(a));
     2 #define max(x,y) (x)>(y)?(x):(y)
     3 #define min(x,y) (x)<(y)?(x):(y)
     4 #define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
     5 #define rep(i,a,b) for(ll i=(a);i<=(b);i++)
     6 #define per(i,b,a) for(ll i=(b);i>=(a);i--)
     7 #include<bits/stdc++.h>
     8 typedef long long ll;
     9 #define PII pair<ll,ll>
    10 using namespace std;
    11 const int INF=0x3f3f3f3f;
    12 const int MAXN=(int)2e6+5;
    13 
    14 char s[MAXN];
    15 stack<char>stk;
    16 map<char,char>mp;
    17 int main()
    18 {
    19     mp['(']=')';
    20     mp[')']='(';
    21     mp['{']='}';
    22     mp['}']='{';
    23     mp['[']=']';
    24     mp[']']='[';
    25     scanf("%s",s);
    26     for(int i=0;s[i];i++){
    27         if(stk.empty())stk.push(s[i]);
    28         else {
    29             if(stk.top()==mp[s[i]])stk.pop();
    30             else stk.push(s[i]);
    31         }
    32     }
    33     printf("%d",stk.empty()?1:0);
    34     return 0;
    35 }
  • 相关阅读:
    vue 快速开发
    java 查es
    es filter 的使用
    es查询例子
    es的基本查询
    linux top命令VIRT,RES,SHR,DATA的含义
    Redis和MC的对比
    决TIME_WAIT过多造成的问题
    MariaDB yum 安装
    more 命令相关
  • 原文地址:https://www.cnblogs.com/dogenya/p/10815675.html
Copyright © 2011-2022 走看看