結果

問題 No.592 括弧の対応 (2)
コンテスト
ユーザー zengyongxu-jerry
提出日時 2026-08-25 20:36:15
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 11 ms / 5,000 ms
+ 724µs
コード長 738 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,082 ms
コンパイル使用メモリ 351,580 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-25 20:36:24
合計ジャッジ時間 4,197 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// <DATETIME>
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define rep(i, x, y) for (int i = (x); i <= (y); i ++ )
#define per(i, x, y) for (int i = (x); i >= (y); i -- )
const int N = 5e5 + 5, M = 1e6 + 5;
const int inf = 1e9, mod = 998244353;
const ll INF = 1e18, RMX = 2324814;
mt19937 rd(time(0));
uniform_int_distribution<int> dist(0, RMX);

int n, pos[N];

signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    cin >> n;
    vector <int> vec;
    rep(i, 1, n){
		char c; cin >> c;
		if (c == '(') vec.push_back(i);
		else pos[i] = vec.back(), pos[vec.back()] = i, vec.pop_back();
	}
	rep(i, 1, n) cout << pos[i] << '\n';
}
0