| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 91790 | sh25_shenpy | 字符串匹配问题(strs) | C++ | 解答错误 | 0 MS | 252 KB | 827 | 2026-06-16 07:07:08 |
#include <bits/stdc++.h> using namespace std; void solve() { stack <char> s ; string str ; cin >> str ; for(int i = 0 ; i < str.size() ; i++ ) { if(s.empty()) s.push(' ') ; if(str[i] == '}') if(s.top() == '{') s.pop() ; else{ cout << "NO\n" ; return ; } else if(str[i] == ']') if(s.top() == ']') s.pop() ; else{ cout << "NO\n" ; return ; } else if(str[i] == ')') if(s.top() == '(') s.pop() ; else{ cout << "NO\n" ; return ; } else if(str[i] == '>') if(s.top() == '<') s.pop() ; else{ cout << "NO\n" ; return ; } else s.push(str[i]) ; } cout << "YES\n" ; } int main() { int n ; cin >> n ; while(n--) solve() ; return 0; }