結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
tokizo
|
| 提出日時 | 2018-01-15 11:21:56 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| + 300µs | |
| コード長 | 735 bytes |
| 記録 | |
| コンパイル時間 | 529 ms |
| コンパイル使用メモリ | 100,636 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-19 18:00:39 |
| 合計ジャッジ時間 | 1,625 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stdio.h>
#include <stack>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
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;
int A[n] = {};
REP(i, n){
if(S[i] == '('){
st.push(i);
continue;
}
int tmp = st.top();
st.pop();
A[i] = tmp;
A[tmp] = i;
}
cout << A[k - 1] + 1 << endl;
return 0;
}
tokizo