提交时间:2023-08-22 16:21:01
运行 ID: 99355
#include <bits/stdc++.h> using namespace std; string s; int cnt=0; char st[1145]; 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]!=s[i]) { cout << "Wrong"; exit(0); } else { cnt--; } } } cout << ((cnt==0)?"OK":"Wrong"); return 0; }