提交时间:2023-08-22 16:08:17

运行 ID: 99304

#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 == '@') break; if (c == '(' || c == '[') { st[cur++] = c; } else if (c == ')' || c == ']') { char target = st[--cur]; if (!((c == ')' && target == '(') || (c == ']' && target == '['))) { cout << "NO" << endl; return 0; } } } if (cur != 0) { cout << "NO" << endl; } else cout << "YES" << endl; return 0; }