結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2016-09-19 01:36:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 2,226 ms |
コンパイル使用メモリ | 171,868 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:16:35 |
合計ジャッジ時間 | 2,695 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(n); i++) using namespace std; struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; int main() { int N, K; string S; cin >> N >> K >> S; stack<int> st; vector<int> res( N ); REP( i, N ) { if( S[i] == '(' ) { st.emplace( i ); continue; } int tmp = st.top(); st.pop(); res[i] = tmp;//left'(' のindex res[tmp] = i;//right')'のindex } cout << res[ K - 1 ] + 1 << endl; return 0; }