2 条题解
- 
  0
#include<iostream> #include<stack> #include<string> using namespace std; const int N = 5e4+10; int a[N],b[N]; int main() { stack<char> stk; string st; cin >> st; int cnt = 0; bool flag = true; int cta = 1 , ctb = 1; for (int i = 0; i < st.size() ; i ++) { if(st[i] == ')'){ if(stk.size() && stk.top() == '(') { b[a[-- cta]] = i + 1; //cout << cnt << " " << i+1 << endl; stk.pop(); }else{ flag = false; //cout << "dd" << endl; break; } }else { stk.push(st[i]); a[cta ++ ] = i + 1; } } if(stk.size()) flag = false; if(flag) { cout << "Yes" << endl; for(int i = 1; i <= st.size(); i ++) { if(b[i] != 0) cout << i << " " << b[i] << endl; } }else cout << "No"; return 0; } 
- 1
 
信息
- ID
 - 138
 - 时间
 - 1000ms
 - 内存
 - 256MiB
 - 难度
 - 7
 - 标签
 - (无)
 - 递交数
 - 148
 - 已通过
 - 32
 - 上传者