結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2019-01-06 16:34:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 456 bytes |
コンパイル時間 | 601 ms |
コンパイル使用メモリ | 70,272 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 23:52:34 |
合計ジャッジ時間 | 1,394 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 13 |
ソースコード
#include <iostream> #include <utility> #include <vector> using namespace std; typedef pair<char, int> PCI; int main(void){ int n,k; vector<PCI> stk; char c; cin >> n >> k; for (int i=1; i<=n; i++){ cin >> c; if (c=='(') stk.push_back(make_pair(c,i)); else { // c==')' PCI pci = stk.back(); if (i==k) cout << pci.second << endl; if (i==pci.second) cout << k << endl; stk.pop_back(); } } return 0; }