比赛 板子大赛 评测结果 AAAAAA
题目名称 多种括号匹配 最终得分 100
用户昵称 TeaWine 运行时间 0.018 s
代码语言 C++ 内存使用 3.29 MiB
提交时间 2025-01-22 09:10:48
显示代码纯文本
#include<bits/stdc++.h>

using namespace std;

string a;

int tmp=1,zh[1086];

int main () {
    
    freopen("check.in","r",stdin);
    freopen("check.out","w",stdout);

    cin>>a;
    
    for(int i = 0; i<a.size(); i++){
        if(a[i]=='[')zh[tmp++]=1;
        if(a[i]=='(')zh[tmp++]=2;
        
        if(a[i]==']'){
            if(zh[tmp-1]!=1){
                cout<<"Wrong";
                return 0;
            }
            tmp--;
        }
        if(a[i]==')'){
            if(zh[tmp-1]!=2){
                cout<<"Wrong";
                return 0;
            }
            tmp--;
        }
    }
    if(tmp>1)cout<<"Wrong";
    else cout<<"OK";
    return 0;
}