結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2019-09-19 01:14:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 697 ms |
コンパイル使用メモリ | 67,672 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:45:14 |
合計ジャッジ時間 | 1,945 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <algorithm> #include <iostream> #include <string> #include <vector> #include <stack> using namespace std; struct Coord { int x, y; }; int main() { int n, k; std::cin >> n >> k; std::vector<int> b(n); std::stack<int> s; for (int i = 0; i < n; i++) { char c; std::cin >> c; if (c == '(') { s.push(i); } else { b[i] = s.top(); b[s.top()] = i; s.pop(); } } std::cout << b[k - 1] + 1 << std::endl; return 0; }