'commit'
This commit is contained in:
25
LuoGu/RuMen/P1739.cpp
Normal file
25
LuoGu/RuMen/P1739.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
stack<char> _a;
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false); //读入输出优化的强迫症
|
||||
string str = "";
|
||||
cin >> str;
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
if (str[i] == '@') break;
|
||||
if (str[i] == '(') _a.push(str[i]);
|
||||
if (str[i] == ')') {
|
||||
if (!_a.empty()) {
|
||||
_a.pop();
|
||||
} else {
|
||||
cout << "NO" << endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_a.empty()) cout << "YES" << endl;//判断有没有多余的(
|
||||
else cout << "NO" << endl;//也就是判断栈是否为空
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user