結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
![]() |
提出日時 | 2017-11-10 23:12:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 240 ms / 5,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 1,091 ms |
コンパイル使用メモリ | 88,440 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 15:06:37 |
合計ジャッジ時間 | 2,094 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <cstdio>#include <vector>#include <map>#include <set>#include <algorithm>#include <string>#include <cstdlib>#include <stack>#include <queue>#include <cmath>#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)#define repp(i,j,k) for(int i=j;i>=k;i--)#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)#define Sort(x) sort(x.begin(),x.end());#define vi vector<int>#define vvi vector<vector<int>>#define ll long longint mod=1e9+7;const int INF = 1e9;using namespace std;int main(void) {int n;string s;cin >> n >> s;vector<int> v(n);stack<int> st;for (int i = 0; i<s.length(); i++) {if (s[i] == '(') st.push(i);if (s[i] == ')') {int temp = st.top();st.pop();v[temp] = i+1;v[i] = temp+1;}}for (int i = 0; i < n; i++) {cout << v[i] << endl;}return 0;}