比赛 |
板子大赛 |
评测结果 |
AAAAAA |
题目名称 |
多种括号匹配 |
最终得分 |
100 |
用户昵称 |
xxz |
运行时间 |
0.019 s |
代码语言 |
C++ |
内存使用 |
3.38 MiB |
提交时间 |
2025-01-22 09:22:16 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int m,n;
string s;
stack<char>c;
int main(){
freopen("check.in","r",stdin);freopen("check.out","w",stdout);
cin>>s;
int l=s.size();
for(int i=0;i<l;i++){
if(s[i]=='('||s[i]=='[')c.push(s[i]);
else if(s[i]==')'){
if(c.empty()||c.top()!='('){
printf("Wrong");
return 0;
}
c.pop();
}else if(s[i]==']'){
if(c.empty()||c.top()!='['){
printf("Wrong");
return 0;
}
c.pop();
}
}
if(c.empty())printf("OK");
else printf("Wrong");
return 0;
}