結果
| 問題 |
No.592 括弧の対応 (2)
|
| コンテスト | |
| ユーザー |
hamray
|
| 提出日時 | 2017-11-10 23:00:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 784 bytes |
| コンパイル時間 | 525 ms |
| コンパイル使用メモリ | 68,532 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-24 13:19:59 |
| 合計ジャッジ時間 | 1,702 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 2 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
using namespace std;
int main() {
int N;
cin >> N;
string S;
cin >> S;
stack<char> leftstk;
stack<char> rightstk;
stack<int> lnum;
stack<int> rnum;
for(int i = 0; i < N; i++){
if(S[i] == '('){
leftstk.push(S[i]);
lnum.push(i);
}else if(S[i] == ')'){
rightstk.push(S[i]);
rnum.push(i);
if(leftstk.top() == '('){
cout << rnum.top() + 1<< endl;
cout << lnum.top() + 1<< endl;
lnum.pop();
rnum.pop();
leftstk.pop();
rightstk.pop();
}
}
}
return 0;
}
hamray