結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-11 23:32:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 519 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 65,668 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-21 09:53:33 |
| 合計ジャッジ時間 | 1,331 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 16 |
ソースコード
#include <iostream>
#include <string>
#include <stack>
#include <queue>
int main()
{
int N; std::cin >> N;
int K; std::cin >> K;
std::string s; std::cin >> s;
std::stack<int> st;
std::queue<int> q;
for(int i=0; i<s.size(); i++)
{
if(s[i]=='(') st.push(i+1);
else q.push(i+1);
}
while(!st.empty())
{
int i = st.top(); st.pop();
int j = q.front(); q.pop();
if(i==K)
{
std::cout << j << std::endl;
break;
}
else if(j==K)
{
std::cout << i << std::endl;
break;
}
}
return 0;
}