提交时间:2023-12-21 13:53:27
运行 ID: 117020
#include<bits/stdc++.h> using namespace std; string s; int m; char stc[100001]; int main(){ cin>>s; for(int i=0;i<s.size();i++){ if(s[i]=='('||s[i]=='['){ m++; stc[m]=s[i]; } else{ if(s[i]==']'){ if(stc[m]!='['){ cout<<"Wrong"<<endl; return 0; } else{ stc[m]=0; m--; } } if(s[i]==')'){ if(stc[m]!='('){ cout<<"Wrong"<<endl; return 0; } else{ stc[m]=0; m--; } } } } if(m==0)cout<<"OK"; else cout<<"Wrong"; return 0; }