結果
問題 | No.22 括弧の対応 |
ユーザー |
|
提出日時 | 2020-12-15 21:31:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 365 bytes |
コンパイル時間 | 1,488 ms |
コンパイル使用メモリ | 170,692 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 02:17:13 |
合計ジャッジ時間 | 2,188 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int memo[10000]; int main() { int N, K; string s; cin >> N >> K >> s; stack<int> st; for (int i = 0; i < N; i++) { if (s[i] == '(') { st.push(i); } else { int x = st.top(); st.pop(); memo[x] = i; memo[i] = x; } } cout << memo[K-1] + 1 << endl; return 0; }