| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 84002 | sh25_shenpy | 括弧匹配检验 | C++ | 通过 | 1 MS | 256 KB | 803 | 2026-02-05 15:22:56 |
#include <iostream> #include <stack> #include <string> using namespace std; int main() { string s; getline(cin, s); stack<char> stk; bool valid = true; for (char c : s) { if (c == '(' || c == '[') { stk.push(c); } else if (c == ')' || c == ']') { if (stk.empty()) { valid = false; break; } char top = stk.top(); if ((c == ')' && top == '(') || (c == ']' && top == '[')) { stk.pop(); } else { valid = false; break; } } } if (valid && stk.empty()) { cout << "OK" << endl; } else { cout << "Wrong" << endl; } return 0; }