結果
問題 | No.22 括弧の対応 |
ユーザー |
|
提出日時 | 2020-01-08 09:59:10 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 2,117 ms |
コンパイル使用メモリ | 95,604 KB |
最終ジャッジ日時 | 2025-01-08 16:55:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <stack> #include <string> int main() { uint32_t _, k; std::cin >> _ >> k; std::string s; std::cin >> s; std::stack<uint32_t> st{}; for (uint32_t i = 0; i < s.length(); ++i) { const uint32_t p = i + 1; if (s.at(i) == '(') { st.push(p); } else { const uint32_t t = st.top(); if (t == k) { std::cout << p << std::endl; } else if (p == k) { std::cout << t << std::endl; } st.pop(); } } }