結果

問題 No.592 括弧の対応 (2)
ユーザー Lepton_sLepton_s
提出日時 2017-11-19 15:41:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 267 ms / 5,000 ms
コード長 1,353 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 88,904 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-08-17 05:05:23
合計ジャッジ時間 2,390 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 265 ms
4,548 KB
testcase_02 AC 266 ms
4,892 KB
testcase_03 AC 267 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 200000
int res[N], x[N];

int main(){
	int n;
	string s;
	cin>>n>>s;
	int t = 0;
	rep(i, n){
		if(s[i]=='(') x[t++] = i;
		else {
			res[i] = x[--t];
			res[res[i]] = i;
		}
	}
	rep(i, n) cout<<res[i]+1<<endl;
	return 0;
}
0