結果

問題 No.592 括弧の対応 (2)
ユーザー kotamanegikotamanegi
提出日時 2017-11-10 22:28:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 243 ms / 5,000 ms
コード長 1,192 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 102,672 KB
実行使用メモリ 4,460 KB
最終ジャッジ日時 2023-08-16 03:02:05
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 243 ms
4,408 KB
testcase_02 AC 234 ms
4,460 KB
testcase_03 AC 240 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int ans[300000] = {};
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	stack<int> wow;
	for (int i = 0;i < s.length();++i) {
		if (s[i] == '(') wow.push(i + 1);
		else {
			int nya = wow.top();
			wow.pop();
			ans[nya] = i + 1;
			ans[i + 1] = nya;
		}
	}
	for (int i = 1;i <= n;++i) {
		cout << ans[i] << endl;
	}
	return 0;
}
0