文章
7
粉丝
0
获赞
12
访问
1.3k
#include<bits/stdc++.h>
using namespace std;
map<char,int> rk={{'{',4},{'[',3},{'(',2},{'<',1}};
int main(){
int n;
cin>>n;
while(n-->0){
string s;
cin>>s;
stack<char> st;
bool valid=true;
for(int i=0;i<s.length();i++){
if(!st.empty()){
char top=st.top();
if(s[i]=='{'||s[i]=='['||s[i]=='('||s[i]=='<'){
if(rk[s[i]]>rk[top]){
valid=false;
...
登录后发布评论
暂无评论,来抢沙发