結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2017-04-11 19:30:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 444 bytes |
コンパイル時間 | 584 ms |
コンパイル使用メモリ | 74,752 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:21:29 |
合計ジャッジ時間 | 1,217 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <stack> using namespace std; int main(){ int N,K; string S; cin >> N >> K >> S; vector<int> p(N+1); stack<int> sta; for(int i=0; i<S.size(); i++){ if(S[i]=='(')sta.push(i+1); else{ p[i+1] = sta.top(); p[sta.top()] = i+1; sta.pop(); } } cout << p[K] << endl; return 0; }