mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 14:58:48 +00:00
27 lines
520 B
C++
27 lines
520 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int n, p;
|
|
string s;
|
|
stack<pair<char, int>> st;
|
|
|
|
int main() {
|
|
cin >> n >> p >> s;
|
|
s = ' ' + s;
|
|
for (int i = 1; i < s.size(); i++) {
|
|
if (s[i] == '{') {
|
|
st.push(make_pair(s[i], i));
|
|
} else if (st.top().second == p) {
|
|
cout << i << endl;
|
|
exit(0);
|
|
} else if (i == p) {
|
|
cout << st.top().second << endl;
|
|
exit(0);
|
|
} else {
|
|
st.pop();
|
|
}
|
|
}
|
|
return 0;
|
|
}
|