提交时间:2023-08-22 16:23:10

运行 ID: 99364

#include <bits/stdc++.h> using namespace std; string s; int cnt=0; char st[1145]; char g(char c) { if(c==')')return'('; if(c==']')return'['; } signed main() { cin >> s; for(int i = 0; i < s.length(); i++) { if(s[i]=='('||s[i]=='[') { st[++cnt]=s[i]; } else if(s[i]==']' || s[i]==')') { if(st[cnt]!=g(s[i])) { cout << "Wrong"; exit(0); } else { cnt--; } } } //cout << cnt << endl; cout << ((cnt==0)?"OK":"Wrong"); return 0; }