Login
Register
Problem list
Online status
Huhu_Miao
:
2025-01-01 10:22:39
/** * author: Huhu_Miao * created: 2025.1.1 10:21:00 (UTC+8) **/ #include
void solve() { std::map
myMap{{')', '('}, {']', '['}, {'}', '{'}}; std::stack
stk; std::string str; std::cin >> str; for (auto elem : str) { if (elem == '(' || elem == '{' || elem == '[') stk.push(elem); else { if (stk.empty() || stk.top() != myMap[elem]) { std::cout << 0 << '\n'; return; } stk.pop(); } } std::cout << stk.empty() << '\n'; } int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int T; std::cin>>T; while(T--) solve(); return 0; }
Post Your Comment