提交时间:2023-08-22 16:27:46

运行 ID: 99392

#include<bits/stdc++.h> using namespace std; int main() { char kh[1000000]; cin >> kh; stack<char> arr; int l = strlen(kh); for (int i = 0; i < l; i++) { if (kh[i] == '(') { arr.push(kh[i]); } else if (kh[i] == ')' && arr.empty() == 0) { arr.pop(); } else if (arr.empty() && kh[i] == ')') { cout << "Wrong"; return 0; } } if (arr.empty()) { cout << "Wrong"; } else { cout << "OK"; } return 0; }