提交时间:2023-08-22 16:02:11
运行 ID: 99277
#include <bits/stdc++.h> using namespace std; char st[10005]; int main() { char s[10005]; int cur=0; cin >> s; for (int i = 0;; i++) { char c = s[i]; if (c == '\0') break; if (c == '(' || c == '[') { st[++cur] = c; } else { char target = st[--cur]; if (!((c == ')' && target == '(') || (c == ']' && target == '['))) { cout << "Wrong" << endl; return 0; } } } cout << "OK" << endl; return 0; }