結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2020-05-05 18:08:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 408 bytes |
コンパイル時間 | 1,703 ms |
コンパイル使用メモリ | 170,256 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:49:32 |
合計ジャッジ時間 | 2,036 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; stack<int> S; int memo[10010]; for (int i = 1; i <= N; i++) { char c; cin >> c; if (c == '(') S.push(i); else { int t = S.top(); S.pop(); memo[i] = t; memo[t] = i; } } cout << memo[K] << endl; }