提交时间:2023-08-22 16:04:19
运行 ID: 99287
#include <bits/stdc++.h> using namespace std; char stk[10005]; int top; int main(){ string a; cin>>a; for(int i = 0;i<a.size();i++){ if(a[i]==')'){ if(top==0||stk[top-1]!='('){ cout<<"Wrong"<<endl; return 0; } else top--; } else if(a[i]==']'){ if(top==0||stk[top-1]!='['){ cout<<"Wrong"<<endl; return 0; } else top--; } else stk[top++] = a[i]; } if(top!=0){ cout<<"Wrong"<<endl; return 0; } cout<<"OK"<<endl; return 0; }