結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2019-09-11 06:53:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 420 bytes |
コンパイル時間 | 1,776 ms |
コンパイル使用メモリ | 173,288 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 16:35:36 |
合計ジャッジ時間 | 5,113 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int n, k, top;string s;stack<int> st;vector<int> v(n);cin >> n >> k >> s;for (int i = 0; i < n; i++) {if (s[i] == '(') {st.push(i);} else {top = st.top();st.pop();v[i] = top;v[top] = i;}}cout << v[k-1]+1 << endl;return 0;}