結果
| 問題 | No.592 括弧の対応 (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-11-10 23:04:14 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 263 ms / 5,000 ms | 
| コード長 | 477 bytes | 
| コンパイル時間 | 760 ms | 
| コンパイル使用メモリ | 61,820 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-24 13:32:19 | 
| 合計ジャッジ時間 | 2,098 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
ソースコード
#include <iostream>
#include <string>
#include <stack>
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int N;
	std::string str;
	std::cin >> N >> str;
	int answer[200000] = {};
	std::stack<int> stack;
	for(int i = 0; i < N; ++i){
		if(str[i] == '('){
			stack.push(i);
		}
		else{
			answer[stack.top()] = i + 1;
			answer[i] = stack.top() + 1;
			stack.pop();
		}
	}
	for(int i = 0; i < N; ++i){
		std::cout << answer[i] << std::endl;
	}
	return 0;
}
            
            
            
        